chumpy-fixed 0.71__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chumpy_fixed-0.71/LICENSE.txt +22 -0
- chumpy_fixed-0.71/MANIFEST.in +3 -0
- chumpy_fixed-0.71/Makefile +18 -0
- chumpy_fixed-0.71/PKG-INFO +31 -0
- chumpy_fixed-0.71/README.md +60 -0
- chumpy_fixed-0.71/chumpy/__init__.py +117 -0
- chumpy_fixed-0.71/chumpy/api_compatibility.py +534 -0
- chumpy_fixed-0.71/chumpy/ch.py +1367 -0
- chumpy_fixed-0.71/chumpy/ch_ops.py +814 -0
- chumpy_fixed-0.71/chumpy/ch_random.py +32 -0
- chumpy_fixed-0.71/chumpy/extras.py +72 -0
- chumpy_fixed-0.71/chumpy/linalg.py +306 -0
- chumpy_fixed-0.71/chumpy/logic.py +39 -0
- chumpy_fixed-0.71/chumpy/monitor.py +149 -0
- chumpy_fixed-0.71/chumpy/np_tensordot.py +228 -0
- chumpy_fixed-0.71/chumpy/optimization.py +161 -0
- chumpy_fixed-0.71/chumpy/optimization_internal.py +455 -0
- chumpy_fixed-0.71/chumpy/reordering.py +454 -0
- chumpy_fixed-0.71/chumpy/test_ch.py +621 -0
- chumpy_fixed-0.71/chumpy/test_inner_composition.py +80 -0
- chumpy_fixed-0.71/chumpy/test_linalg.py +272 -0
- chumpy_fixed-0.71/chumpy/test_optimization.py +204 -0
- chumpy_fixed-0.71/chumpy/testing.py +21 -0
- chumpy_fixed-0.71/chumpy/utils.py +93 -0
- chumpy_fixed-0.71/chumpy/version.py +3 -0
- chumpy_fixed-0.71/chumpy_fixed.egg-info/PKG-INFO +31 -0
- chumpy_fixed-0.71/chumpy_fixed.egg-info/SOURCES.txt +31 -0
- chumpy_fixed-0.71/chumpy_fixed.egg-info/dependency_links.txt +1 -0
- chumpy_fixed-0.71/chumpy_fixed.egg-info/requires.txt +3 -0
- chumpy_fixed-0.71/chumpy_fixed.egg-info/top_level.txt +1 -0
- chumpy_fixed-0.71/requirements.txt +3 -0
- chumpy_fixed-0.71/setup.cfg +4 -0
- chumpy_fixed-0.71/setup.py +55 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Max-Planck-Gesellschaft
|
|
4
|
+
Copyright (c) 2014 Matthew Loper
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
all:
|
|
2
|
+
|
|
3
|
+
upload:
|
|
4
|
+
rm -r dist
|
|
5
|
+
python setup.py sdist
|
|
6
|
+
twine upload dist/*
|
|
7
|
+
|
|
8
|
+
test:
|
|
9
|
+
# For some reason the import changes for Python 3 caused the Python 2 test
|
|
10
|
+
# loader to give up without loading any tests. So we discover them ourselves.
|
|
11
|
+
# python -m unittest
|
|
12
|
+
find chumpy -name 'test_*.py' | sed -e 's/\.py$$//' -e 's/\//./' | xargs python -m unittest
|
|
13
|
+
|
|
14
|
+
coverage: clean qcov
|
|
15
|
+
qcov: all
|
|
16
|
+
env LD_PRELOAD=$(PRELOADED) coverage run --source=. -m unittest discover -s .
|
|
17
|
+
coverage html
|
|
18
|
+
coverage report -m
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chumpy-fixed
|
|
3
|
+
Version: 0.71
|
|
4
|
+
Summary: chumpy
|
|
5
|
+
Home-page: https://github.com/mattloper/chumpy
|
|
6
|
+
Author: Matthew Loper
|
|
7
|
+
Author-email: matt.loper@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 2
|
|
14
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Requires-Python: >=2.7
|
|
19
|
+
License-File: LICENSE.txt
|
|
20
|
+
Requires-Dist: numpy>=1.8.1
|
|
21
|
+
Requires-Dist: scipy>=0.13.0
|
|
22
|
+
Requires-Dist: six>=1.11.0
|
|
23
|
+
Dynamic: author
|
|
24
|
+
Dynamic: author-email
|
|
25
|
+
Dynamic: classifier
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: license
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
Dynamic: requires-dist
|
|
30
|
+
Dynamic: requires-python
|
|
31
|
+
Dynamic: summary
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
chumpy
|
|
2
|
+
======
|
|
3
|
+
|
|
4
|
+
[][pypi]
|
|
5
|
+
[][pypi]
|
|
6
|
+
[][pypi]
|
|
7
|
+
[][circle]
|
|
8
|
+
|
|
9
|
+
Autodifferentiation tool for Python.
|
|
10
|
+
|
|
11
|
+
[circle]: https://circleci.com/gh/mattloper/chumpy
|
|
12
|
+
[pypi]: https://pypi.org/project/chumpy/
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Installation
|
|
16
|
+
------------
|
|
17
|
+
|
|
18
|
+
Install the fork:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
pip install chumpy
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Import it:
|
|
25
|
+
|
|
26
|
+
```py
|
|
27
|
+
import chumpy as ch
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Overview
|
|
31
|
+
--------
|
|
32
|
+
|
|
33
|
+
Chumpy is a Python-based framework designed to handle the **auto-differentiation** problem,
|
|
34
|
+
which is to evaluate an expression and its derivatives with respect to its inputs, by use of the chain rule.
|
|
35
|
+
|
|
36
|
+
Chumpy is intended to make construction and local
|
|
37
|
+
minimization of objectives easier.
|
|
38
|
+
|
|
39
|
+
Specifically, it provides:
|
|
40
|
+
|
|
41
|
+
- Easy problem construction by using Numpy’s application interface
|
|
42
|
+
- Easy access to derivatives via auto differentiation
|
|
43
|
+
- Easy local optimization methods (12 of them: most of which use the derivatives)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
Usage
|
|
47
|
+
-----
|
|
48
|
+
|
|
49
|
+
Chumpy comes with its own demos, which can be seen by typing the following:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import chumpy
|
|
53
|
+
chumpy.demo() # prints out a list of possible demos
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
License
|
|
58
|
+
-------
|
|
59
|
+
|
|
60
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
from .ch import *
|
|
2
|
+
from .logic import *
|
|
3
|
+
|
|
4
|
+
from .optimization import minimize
|
|
5
|
+
from . import extras
|
|
6
|
+
from . import testing
|
|
7
|
+
from .version import version as __version__
|
|
8
|
+
|
|
9
|
+
from .version import version as __version__
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test():
|
|
13
|
+
from os.path import split
|
|
14
|
+
import unittest
|
|
15
|
+
test_loader= unittest.TestLoader()
|
|
16
|
+
test_loader = test_loader.discover(split(__file__)[0])
|
|
17
|
+
test_runner = unittest.TextTestRunner()
|
|
18
|
+
test_runner.run( test_loader )
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
demos = {}
|
|
22
|
+
|
|
23
|
+
demos['scalar'] = """
|
|
24
|
+
import chumpy as ch
|
|
25
|
+
|
|
26
|
+
[x1, x2, x3] = ch.array(10), ch.array(20), ch.array(30)
|
|
27
|
+
result = x1+x2+x3
|
|
28
|
+
print result # prints [ 60.]
|
|
29
|
+
print result.dr_wrt(x1) # prints 1
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
demos['show_tree'] = """
|
|
33
|
+
import chumpy as ch
|
|
34
|
+
|
|
35
|
+
[x1, x2, x3] = ch.array(10), ch.array(20), ch.array(30)
|
|
36
|
+
for i in range(3): x2 = x1 + x2 + x3
|
|
37
|
+
|
|
38
|
+
x2.dr_wrt(x1) # pull cache
|
|
39
|
+
x2.dr_wrt(x3) # pull cache
|
|
40
|
+
x1.label='x1' # for clarity in show_tree()
|
|
41
|
+
x2.label='x2' # for clarity in show_tree()
|
|
42
|
+
x3.label='x3' # for clarity in show_tree()
|
|
43
|
+
x2.show_tree(cachelim=1e-4) # in MB
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
demos['matrix'] = """
|
|
47
|
+
import chumpy as ch
|
|
48
|
+
|
|
49
|
+
x1, x2, x3, x4 = ch.eye(10), ch.array(1), ch.array(5), ch.array(10)
|
|
50
|
+
y = x1*(x2-x3)+x4
|
|
51
|
+
print y
|
|
52
|
+
print y.dr_wrt(x2)
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
demos['linalg'] = """
|
|
56
|
+
import chumpy as ch
|
|
57
|
+
|
|
58
|
+
m = [ch.random.randn(100).reshape((10,10)) for i in range(3)]
|
|
59
|
+
y = m[0].dot(m[1]).dot(ch.linalg.inv(m[2])) * ch.linalg.det(m[0])
|
|
60
|
+
print y.shape
|
|
61
|
+
print y.dr_wrt(m[0]).shape
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
demos['inheritance'] = """
|
|
65
|
+
import chumpy as ch
|
|
66
|
+
import numpy as np
|
|
67
|
+
|
|
68
|
+
class Sin(ch.Ch):
|
|
69
|
+
|
|
70
|
+
dterms = ('x',)
|
|
71
|
+
|
|
72
|
+
def compute_r(self):
|
|
73
|
+
return np.sin(self.x.r)
|
|
74
|
+
|
|
75
|
+
def compute_dr_wrt(self, wrt):
|
|
76
|
+
import scipy.sparse
|
|
77
|
+
if wrt is self.x:
|
|
78
|
+
result = np.cos(self.x.r)
|
|
79
|
+
return scipy.sparse.diags([result.ravel()], [0]) if len(result)>1 else np.atleast_2d(result)
|
|
80
|
+
|
|
81
|
+
x1 = Ch([10,20,30])
|
|
82
|
+
result = Sin(x1) # or "result = Sin(x=x1)"
|
|
83
|
+
print result.r
|
|
84
|
+
print result.dr_wrt(x1)
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
demos['optimization'] = """
|
|
88
|
+
import chumpy as ch
|
|
89
|
+
|
|
90
|
+
x = ch.zeros(10)
|
|
91
|
+
y = ch.zeros(10)
|
|
92
|
+
|
|
93
|
+
# Beale's function
|
|
94
|
+
e1 = 1.5 - x + x*y
|
|
95
|
+
e2 = 2.25 - x + x*(y**2)
|
|
96
|
+
e3 = 2.625 - x + x*(y**3)
|
|
97
|
+
|
|
98
|
+
objective = {'e1': e1, 'e2': e2, 'e3': e3}
|
|
99
|
+
ch.minimize(objective, x0=[x,y], method='dogleg')
|
|
100
|
+
print x # should be all 3.0
|
|
101
|
+
print y # should be all 0.5
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def demo(which=None):
|
|
108
|
+
if which not in demos:
|
|
109
|
+
print('Please indicate which demo you want, as follows:')
|
|
110
|
+
for key in demos:
|
|
111
|
+
print("\tdemo('%s')" % (key,))
|
|
112
|
+
return
|
|
113
|
+
|
|
114
|
+
print('- - - - - - - - - - - <CODE> - - - - - - - - - - - -')
|
|
115
|
+
print(demos[which])
|
|
116
|
+
print('- - - - - - - - - - - </CODE> - - - - - - - - - - - -\n')
|
|
117
|
+
exec('global np\n' + demos[which], globals(), locals())
|