diffpy.srfit 3.1.0__tar.gz → 3.2.0__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.
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/LICENSE.rst +9 -13
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/PKG-INFO +2 -2
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/pyproject.toml +1 -1
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/requirements/docs.txt +1 -1
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/builder.py +109 -62
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/equationmod.py +33 -16
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/literals/argument.py +14 -6
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/literals/literal.py +5 -2
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/literals/operators.py +4 -1
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/visitors/__init__.py +11 -5
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/visitors/argfinder.py +10 -5
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/visitors/printer.py +8 -4
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/visitors/swapper.py +13 -6
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/visitors/validator.py +7 -4
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/calculator.py +40 -20
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/configurable.py +5 -3
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/constraint.py +6 -3
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/fitcontribution.py +88 -50
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/fithook.py +40 -14
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/fitrecipe.py +178 -93
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/fitresults.py +148 -71
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/parameter.py +120 -62
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/parameterset.py +38 -17
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/profile.py +76 -38
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/profilegenerator.py +72 -37
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/profileparser.py +58 -35
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/recipeorganizer.py +201 -98
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/restraint.py +41 -21
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/simplerecipe.py +95 -52
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/interface/interface.py +4 -1
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/pdf/basepdfgenerator.py +89 -53
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/pdf/characteristicfunctions.py +74 -27
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/pdf/debyepdfgenerator.py +74 -45
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/pdf/pdfcontribution.py +103 -62
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/pdf/pdfgenerator.py +45 -27
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/pdf/pdfparser.py +70 -38
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/sas/prcalculator.py +40 -23
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/sas/sasgenerator.py +17 -11
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/sas/sasimport.py +4 -1
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/sas/sasparameter.py +29 -15
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/sas/sasparser.py +67 -34
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/sas/sasprofile.py +56 -30
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/structure/__init__.py +6 -2
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/structure/basestructureparset.py +4 -2
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/structure/bvsrestraint.py +27 -14
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/structure/cctbxparset.py +55 -22
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/structure/diffpyparset.py +81 -42
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/structure/objcrystparset.py +690 -381
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/structure/sgconstraints.py +153 -84
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/structure/srrealparset.py +16 -9
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/util/inpututils.py +6 -2
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/util/tagmanager.py +23 -9
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy.srfit.egg-info/PKG-INFO +2 -2
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy.srfit.egg-info/SOURCES.txt +1 -1
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/conftest.py +5 -3
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_characteristicfunctions.py +49 -15
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_pdf.py +9 -6
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_sas.py +17 -8
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/AUTHORS.rst +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/LICENSE_DANSE.rst +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/MANIFEST.in +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/README.rst +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/requirements/build.txt +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/requirements/conda.txt +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/requirements/pip.txt +0 -0
- /diffpy_srfit-3.1.0/requirements/test.txt → /diffpy_srfit-3.2.0/requirements/tests.txt +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/setup.cfg +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/__init__.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/__init__.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/__init__.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/literals/__init__.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/literals/abcs.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/equation/visitors/visitor.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/exceptions.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/__init__.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/fitbase/validatable.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/interface/__init__.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/pdf/__init__.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/sas/__init__.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/util/__init__.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/util/argbinders.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/util/nameutils.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/util/observable.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/util/weakrefcallable.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy/srfit/version.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy.srfit.egg-info/dependency_links.txt +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy.srfit.egg-info/requires.txt +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/src/diffpy.srfit.egg-info/top_level.txt +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/__init__.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/debug.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/run.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_builder.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_constraint.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_contribution.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_diffpyparset.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_equation.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_fitrecipe.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_fitresults.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_literals.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_objcrystparset.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_parameter.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_parameterset.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_profile.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_profilegenerator.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_recipeorganizer.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_restraint.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_sgconstraints.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_speed.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_tagmanager.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_version.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_visitors.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/test_weakrefcallable.py +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/testdata/LaMnO3.stru +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/testdata/ni-q27r100-neutron.gr +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/testdata/ni.cif +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/testdata/results.res +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/testdata/sas_ascii_test_1.txt +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/testdata/sas_ellipsoid_testdata.txt +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/testdata/si-q27r60-xray.gr +0 -0
- {diffpy_srfit-3.1.0 → diffpy_srfit-3.2.0}/tests/testdata/testdata.txt +0 -0
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
OPEN SOURCE LICENSE AGREEMENT
|
|
2
2
|
=============================
|
|
3
3
|
|
|
4
|
-
Copyright (c) 2009-2011, University of Tennessee
|
|
5
|
-
Copyright (c) 1989, 1991 Free Software Foundation, Inc.
|
|
6
|
-
Copyright (c) 2006, The Regents of the University of California through
|
|
7
|
-
|
|
8
|
-
Copyright (c)
|
|
9
|
-
Copyright (c)
|
|
10
|
-
Copyright (c)
|
|
11
|
-
|
|
12
|
-
Copyright (c) 2014-2019, Brookhaven Science Associates, Brookhaven National
|
|
13
|
-
Laboratory
|
|
14
|
-
Copyright (c) 2020-2025, The Trustees of Columbia University in the City
|
|
15
|
-
of New York
|
|
4
|
+
- Copyright (c) 2009-2011, University of Tennessee
|
|
5
|
+
- Copyright (c) 1989, 1991 Free Software Foundation, Inc.
|
|
6
|
+
- Copyright (c) 2006, The Regents of the University of California through Lawrence Berkeley National Laboratory
|
|
7
|
+
- Copyright (c) 2014, Australian Synchrotron Research Program Inc., ("ASRP")
|
|
8
|
+
- Copyright (c) 2006-2007, Board of Trustees of Michigan State University
|
|
9
|
+
- Copyright (c) 2008-2012, The Trustees of Columbia University in the City of New York
|
|
10
|
+
- Copyright (c) 2014-2019, Brookhaven Science Associates, Brookhaven National Laboratory
|
|
11
|
+
- Copyright (c) 2020-2025, The Trustees of Columbia University in the City of New York
|
|
16
12
|
|
|
17
13
|
|
|
18
14
|
The "DiffPy-CMI" is distributed subject to the following license conditions:
|
|
@@ -20,7 +16,7 @@ The "DiffPy-CMI" is distributed subject to the following license conditions:
|
|
|
20
16
|
|
|
21
17
|
SOFTWARE LICENSE AGREEMENT
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
**Software:** DiffPy-CMI
|
|
24
20
|
|
|
25
21
|
|
|
26
22
|
(1) The "Software", below, refers to the aforementioned DiffPy-CMI (in either
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffpy.srfit
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: Configurable code for solving atomic structures.
|
|
5
5
|
Author-email: Simon Billinge <sb2896@columbia.edu>
|
|
6
6
|
Maintainer-email: Simon Billinge <sb2896@columbia.edu>
|
|
@@ -11,7 +11,7 @@ Classifier: Development Status :: 5 - Production/Stable
|
|
|
11
11
|
Classifier: Environment :: Console
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
13
|
Classifier: Intended Audience :: Science/Research
|
|
14
|
-
Classifier: License ::
|
|
14
|
+
Classifier: License :: Free To Use But Restricted
|
|
15
15
|
Classifier: Operating System :: MacOS :: MacOS X
|
|
16
16
|
Classifier: Operating System :: Microsoft :: Windows
|
|
17
17
|
Classifier: Operating System :: POSIX
|
|
@@ -20,7 +20,7 @@ classifiers = [
|
|
|
20
20
|
'Environment :: Console',
|
|
21
21
|
'Intended Audience :: Developers',
|
|
22
22
|
'Intended Audience :: Science/Research',
|
|
23
|
-
'License ::
|
|
23
|
+
'License :: Free To Use But Restricted',
|
|
24
24
|
'Operating System :: MacOS :: MacOS X',
|
|
25
25
|
'Operating System :: Microsoft :: Windows',
|
|
26
26
|
'Operating System :: POSIX',
|
|
@@ -109,12 +109,17 @@ _builders = {}
|
|
|
109
109
|
class EquationFactory(object):
|
|
110
110
|
"""A Factory for equations.
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
Attributes
|
|
113
|
+
----------
|
|
114
|
+
builders
|
|
115
|
+
A dictionary of BaseBuilders registered with the
|
|
116
|
+
factory, indexed by name.
|
|
117
|
+
newargs
|
|
118
|
+
A set of new arguments created by makeEquation. This is
|
|
119
|
+
redefined whenever makeEquation is called.
|
|
120
|
+
equations
|
|
121
|
+
Set of equations that have been built by the
|
|
122
|
+
EquationFactory.
|
|
118
123
|
"""
|
|
119
124
|
|
|
120
125
|
symbols = ("+", "-", "*", "/", "**", "%", "|")
|
|
@@ -137,21 +142,26 @@ class EquationFactory(object):
|
|
|
137
142
|
):
|
|
138
143
|
"""Make an equation from an equation string.
|
|
139
144
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
145
|
+
Parameters
|
|
146
|
+
----------
|
|
147
|
+
eqstr
|
|
148
|
+
An equation in string form using standard python
|
|
149
|
+
syntax. The equation string can use any function
|
|
150
|
+
registered literal or function, including numpy ufuncs
|
|
151
|
+
that are automatically registered.
|
|
152
|
+
buildargs
|
|
153
|
+
A flag indicating whether missing arguments can be
|
|
154
|
+
created by the Factory (default True). If False, then
|
|
155
|
+
the a ValueError will be raised if there are undefined
|
|
156
|
+
arguments in the eqstr. Built arguments will be of type
|
|
157
|
+
argclass.
|
|
158
|
+
argclass
|
|
159
|
+
Class to use when creating new Arguments (default
|
|
160
|
+
diffpy.srfit.equation.literals.Argument). The class
|
|
161
|
+
constructor must accept the 'name' key word.
|
|
162
|
+
argkw
|
|
163
|
+
Key word dictionary to pass to the argclass constructor
|
|
164
|
+
(default {}).
|
|
155
165
|
|
|
156
166
|
Returns a callable Literal representing the equation string.
|
|
157
167
|
"""
|
|
@@ -202,11 +212,16 @@ class EquationFactory(object):
|
|
|
202
212
|
|
|
203
213
|
This will register a builder for the function.
|
|
204
214
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
215
|
+
Attributes
|
|
216
|
+
----------
|
|
217
|
+
name
|
|
218
|
+
The name of the function
|
|
219
|
+
func
|
|
220
|
+
A callable python object
|
|
221
|
+
argnames
|
|
222
|
+
The argument names for func. If these names do not
|
|
223
|
+
correspond to builders, then new constants with value 0
|
|
224
|
+
will be created for each name.
|
|
210
225
|
|
|
211
226
|
Returns the registered builder.
|
|
212
227
|
"""
|
|
@@ -293,17 +308,22 @@ class EquationFactory(object):
|
|
|
293
308
|
arguments, and creates new arguments if allowed. In the process it
|
|
294
309
|
rebuilds the newargs attribute.
|
|
295
310
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
311
|
+
Parameters
|
|
312
|
+
----------
|
|
313
|
+
eqstr
|
|
314
|
+
An equation in string as specified in the makeEquation
|
|
315
|
+
method.
|
|
316
|
+
buildargs
|
|
317
|
+
A flag indicating whether missing arguments can be
|
|
318
|
+
created by the factory. If False, then the a ValueError
|
|
319
|
+
will be raised if there are undefined arguments in the
|
|
320
|
+
eqstr.
|
|
321
|
+
argclass
|
|
322
|
+
Class to use when creating new Arguments. The class
|
|
323
|
+
constructor must accept the 'name' key word.
|
|
324
|
+
argkw
|
|
325
|
+
Key word dictionary to pass to the argclass
|
|
326
|
+
constructor.
|
|
307
327
|
|
|
308
328
|
Raises ValueError if new arguments must be created, but this is
|
|
309
329
|
disallowed due to the buildargs flag.
|
|
@@ -392,7 +412,9 @@ class BaseBuilder(object):
|
|
|
392
412
|
arguments can be other BaseBuilder instances or constants.
|
|
393
413
|
|
|
394
414
|
Attributes
|
|
395
|
-
|
|
415
|
+
----------
|
|
416
|
+
literal
|
|
417
|
+
The equation Literal being built by this instance.
|
|
396
418
|
"""
|
|
397
419
|
|
|
398
420
|
def __init__(self):
|
|
@@ -424,8 +446,11 @@ class BaseBuilder(object):
|
|
|
424
446
|
|
|
425
447
|
Other can be an BaseBuilder or a constant.
|
|
426
448
|
|
|
427
|
-
|
|
428
|
-
|
|
449
|
+
Attributes
|
|
450
|
+
----------
|
|
451
|
+
onleft
|
|
452
|
+
Indicates that the operator was passed on the left side
|
|
453
|
+
(default True).
|
|
429
454
|
"""
|
|
430
455
|
# Create the Operator
|
|
431
456
|
op = OperatorClass()
|
|
@@ -520,20 +545,27 @@ class ArgumentBuilder(BaseBuilder):
|
|
|
520
545
|
arguments can be other BaseBuilder instances or constants.
|
|
521
546
|
|
|
522
547
|
Attributes
|
|
523
|
-
|
|
548
|
+
----------
|
|
549
|
+
literal
|
|
550
|
+
The Argument wrapped by this instance.
|
|
524
551
|
"""
|
|
525
552
|
|
|
526
553
|
def __init__(self, value=None, name=None, const=False, arg=None):
|
|
527
554
|
"""Create an ArgumentBuilder instance, containing a new Argument.
|
|
528
555
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
556
|
+
Parameters
|
|
557
|
+
----------
|
|
558
|
+
value
|
|
559
|
+
The value of the wrapped Argument (float, default None)
|
|
560
|
+
name
|
|
561
|
+
The name of the wrapped Argument (string, default None)
|
|
562
|
+
const
|
|
563
|
+
Flag indicating whether the Argument is constant (bool,
|
|
564
|
+
default False)
|
|
565
|
+
arg
|
|
566
|
+
A pre-defined Argument to use. If this is None (default),
|
|
567
|
+
then a new Argument will be created from value, name and
|
|
568
|
+
const.
|
|
537
569
|
"""
|
|
538
570
|
BaseBuilder.__init__(self)
|
|
539
571
|
if arg is None:
|
|
@@ -552,19 +584,25 @@ class OperatorBuilder(BaseBuilder):
|
|
|
552
584
|
"""BaseBuilder wrapper around an Operator literal.
|
|
553
585
|
|
|
554
586
|
Attributes
|
|
555
|
-
|
|
556
|
-
|
|
587
|
+
----------
|
|
588
|
+
literal
|
|
589
|
+
The Operator wrapped by this instance.
|
|
590
|
+
name
|
|
591
|
+
The name of the operator to be wrapped
|
|
557
592
|
"""
|
|
558
593
|
|
|
559
594
|
def __init__(self, name, op=None):
|
|
560
595
|
"""Wrap an Operator or a function by name.
|
|
561
596
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
597
|
+
Parameters
|
|
598
|
+
----------
|
|
599
|
+
name
|
|
600
|
+
The name of the wrapped Operator
|
|
601
|
+
op
|
|
602
|
+
If specified, this sets the literal attribute as this
|
|
603
|
+
operator (default None). Otherwise, the name is assumed to
|
|
604
|
+
be that of a numpy ufunc, which is used to specify the
|
|
605
|
+
Operator.
|
|
568
606
|
"""
|
|
569
607
|
BaseBuilder.__init__(self)
|
|
570
608
|
self.name = name
|
|
@@ -576,7 +614,10 @@ class OperatorBuilder(BaseBuilder):
|
|
|
576
614
|
|
|
577
615
|
This creates a new builder that encapsulates the operation.
|
|
578
616
|
|
|
579
|
-
|
|
617
|
+
Attributes
|
|
618
|
+
----------
|
|
619
|
+
args
|
|
620
|
+
Arguments of the operation.
|
|
580
621
|
|
|
581
622
|
Raises ValueError if self.literal.nin >= 0 and len(args) != op.nin
|
|
582
623
|
"""
|
|
@@ -637,10 +678,16 @@ def wrapOperator(name, op):
|
|
|
637
678
|
def wrapFunction(name, func, nin=2, nout=1):
|
|
638
679
|
"""Wrap a function in an OperatorBuilder instance.
|
|
639
680
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
681
|
+
Attributes
|
|
682
|
+
----------
|
|
683
|
+
name
|
|
684
|
+
The name of the function
|
|
685
|
+
func
|
|
686
|
+
A callable python object
|
|
687
|
+
nin
|
|
688
|
+
The number of input arguments (default 2)
|
|
689
|
+
nout
|
|
690
|
+
The number of return values (default 1)
|
|
644
691
|
|
|
645
692
|
Returns the OperatorBuilder instance that wraps the function.
|
|
646
693
|
"""
|
|
@@ -56,19 +56,32 @@ class Equation(Operator):
|
|
|
56
56
|
accepts new argument values for the literal tree.
|
|
57
57
|
|
|
58
58
|
Attributes
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
----------
|
|
60
|
+
root
|
|
61
|
+
The root Literal of the equation tree
|
|
62
|
+
argdict
|
|
63
|
+
An OrderedDict of Arguments from the root.
|
|
64
|
+
args
|
|
65
|
+
Property that gets the values of argdict.
|
|
62
66
|
|
|
63
67
|
Operator Attributes
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
-------------------
|
|
69
|
+
args
|
|
70
|
+
List of Literal arguments, set with 'addLiteral'
|
|
71
|
+
name
|
|
72
|
+
A name for this operator. e.g. "add" or "sin"
|
|
73
|
+
nin
|
|
74
|
+
Number of inputs (<1 means this is variable)
|
|
75
|
+
nout
|
|
76
|
+
Number of outputs
|
|
77
|
+
operation
|
|
78
|
+
Function that performs the operation. e.g. numpy.add.
|
|
79
|
+
symbol
|
|
80
|
+
The symbolic representation. e.g. "+" or "sin".
|
|
81
|
+
_value
|
|
82
|
+
The value of the Operator.
|
|
83
|
+
value
|
|
84
|
+
Property for 'getValue'.
|
|
72
85
|
"""
|
|
73
86
|
|
|
74
87
|
# define abstract attributes from the Operator base.
|
|
@@ -78,10 +91,14 @@ class Equation(Operator):
|
|
|
78
91
|
def __init__(self, name=None, root=None):
|
|
79
92
|
"""Initialize.
|
|
80
93
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
94
|
+
Attributes
|
|
95
|
+
----------
|
|
96
|
+
name
|
|
97
|
+
A name for this Equation.
|
|
98
|
+
root
|
|
99
|
+
The root node of the Literal tree (default None). If root
|
|
100
|
+
is not passed here, you must call the 'setRoot' method to
|
|
101
|
+
set or change the root node.
|
|
85
102
|
"""
|
|
86
103
|
# Operator stuff. We circumvent Operator.__init__ since we're using
|
|
87
104
|
# args as a property. We cannot set it, as the Operator tries to do.
|
|
@@ -127,7 +144,7 @@ class Equation(Operator):
|
|
|
127
144
|
)
|
|
128
145
|
|
|
129
146
|
def __dir__(self):
|
|
130
|
-
"Return sorted list of attributes for this object."
|
|
147
|
+
"""Return sorted list of attributes for this object."""
|
|
131
148
|
rv = set(dir(type(self)))
|
|
132
149
|
rv.update(self.__dict__, self.argdict)
|
|
133
150
|
rv = sorted(rv)
|
|
@@ -30,11 +30,16 @@ class Argument(Literal, ArgumentABC):
|
|
|
30
30
|
"""Argument class.
|
|
31
31
|
|
|
32
32
|
Attributes
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
----------
|
|
34
|
+
name
|
|
35
|
+
A name for this Argument.
|
|
36
|
+
const
|
|
37
|
+
A flag indicating whether this is considered a constant.
|
|
38
|
+
Constants may be given special treatment by the Visitors.
|
|
39
|
+
_value
|
|
40
|
+
The value of the Argument. Modified with 'setValue'.
|
|
41
|
+
value
|
|
42
|
+
Property for 'getValue' and 'setValue'.
|
|
38
43
|
"""
|
|
39
44
|
|
|
40
45
|
const = None
|
|
@@ -57,7 +62,10 @@ class Argument(Literal, ArgumentABC):
|
|
|
57
62
|
def setValue(self, val):
|
|
58
63
|
"""Set the value of the Literal.
|
|
59
64
|
|
|
60
|
-
|
|
65
|
+
Attributes
|
|
66
|
+
----------
|
|
67
|
+
val
|
|
68
|
+
The value to assign
|
|
61
69
|
"""
|
|
62
70
|
if isinstance(self._value, ndarray) or isinstance(val, ndarray):
|
|
63
71
|
notequiv = not array_equal(self._value, val)
|
|
@@ -31,8 +31,11 @@ class Literal(Observable, LiteralABC):
|
|
|
31
31
|
Literal derives from Observable. See diffpy.srfit.util.observable.
|
|
32
32
|
|
|
33
33
|
Attributes
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
----------
|
|
35
|
+
name
|
|
36
|
+
A name for this Literal (default None).
|
|
37
|
+
_value
|
|
38
|
+
The value of the Literal.
|
|
36
39
|
"""
|
|
37
40
|
|
|
38
41
|
name = None
|
|
@@ -35,8 +35,11 @@ from diffpy.srfit.equation.visitors.validator import Validator
|
|
|
35
35
|
def getArgs(literal, getconsts=True):
|
|
36
36
|
"""Get the Arguments of a Literal tree.
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
Attributes
|
|
39
|
+
----------
|
|
40
|
+
getconsts
|
|
41
|
+
If True (default), then Arguments designated as constant
|
|
42
|
+
are also retrieved.
|
|
40
43
|
|
|
41
44
|
Returns a list of Arguments searched for depth-first.
|
|
42
45
|
"""
|
|
@@ -47,9 +50,12 @@ def getArgs(literal, getconsts=True):
|
|
|
47
50
|
def getExpression(literal, eqskip=None):
|
|
48
51
|
"""Get math expression string from the Literal tree object.
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
Attributes
|
|
54
|
+
----------
|
|
55
|
+
eqskip
|
|
56
|
+
regular expression pattern for Equation objects that should
|
|
57
|
+
be printed under their own name. Expand all Equation objects
|
|
58
|
+
when None.
|
|
53
59
|
|
|
54
60
|
Return string.
|
|
55
61
|
"""
|
|
@@ -26,16 +26,21 @@ class ArgFinder(Visitor):
|
|
|
26
26
|
"""ArgFinder extracts Arguments from a Literal tree.
|
|
27
27
|
|
|
28
28
|
Attributes
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
----------
|
|
30
|
+
args
|
|
31
|
+
The list of collected Arguments
|
|
32
|
+
getconsts
|
|
33
|
+
Flag indicating whether to grab constant arguments.
|
|
31
34
|
"""
|
|
32
35
|
|
|
33
36
|
def __init__(self, getconsts=True):
|
|
34
37
|
"""Initialize.
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
getconsts
|
|
42
|
+
Flag indicating whether to parse constant arguments
|
|
43
|
+
(default True).
|
|
39
44
|
"""
|
|
40
45
|
self.args = []
|
|
41
46
|
self.getconsts = getconsts
|
|
@@ -30,10 +30,14 @@ class Printer(Visitor):
|
|
|
30
30
|
|
|
31
31
|
Attributes:
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
Attributes
|
|
34
|
+
----------
|
|
35
|
+
eqskip
|
|
36
|
+
regular expression pattern for Equation objects that should
|
|
37
|
+
not be expanded, but printed under their own name. Expand
|
|
38
|
+
all equations when None.
|
|
39
|
+
output
|
|
40
|
+
The output generated by the printer.
|
|
37
41
|
"""
|
|
38
42
|
|
|
39
43
|
# store compiled RE pattern for eqskip or None when none.
|
|
@@ -25,17 +25,24 @@ class Swapper(Visitor):
|
|
|
25
25
|
Note that this cannot swap out a root node of a literal tree. This case
|
|
26
26
|
must be tested for explicitly.
|
|
27
27
|
|
|
28
|
-
Attributes
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
Attributes
|
|
29
|
+
----------
|
|
30
|
+
newlit
|
|
31
|
+
The literal to be placed into the literal tree.
|
|
32
|
+
oldlit
|
|
33
|
+
The literal to be replaced.
|
|
31
34
|
"""
|
|
32
35
|
|
|
33
36
|
def __init__(self, oldlit, newlit):
|
|
34
37
|
"""Initialize.
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
Attributes
|
|
40
|
+
----------
|
|
41
|
+
oldlit
|
|
42
|
+
The literal to be replaced.
|
|
43
|
+
newlit
|
|
44
|
+
The literal to be placed into the literal tree. See the
|
|
45
|
+
class for how the replacement takes place.
|
|
39
46
|
"""
|
|
40
47
|
|
|
41
48
|
self.newlit = newlit
|
|
@@ -34,10 +34,13 @@ msg = "'%s' does not have the interface required by '%s'"
|
|
|
34
34
|
class Validator(Visitor):
|
|
35
35
|
"""Validator error for checking validity of an equation tree.
|
|
36
36
|
|
|
37
|
-
Attributes
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
Attributes
|
|
38
|
+
----------
|
|
39
|
+
errors
|
|
40
|
+
List of strings describing errors.
|
|
41
|
+
_nin
|
|
42
|
+
Variable for counting the number input arguments for an
|
|
43
|
+
operator.
|
|
41
44
|
"""
|
|
42
45
|
|
|
43
46
|
def __init__(self):
|
|
@@ -36,30 +36,50 @@ class Calculator(Operator, ParameterSet):
|
|
|
36
36
|
calculate a generic signal.
|
|
37
37
|
|
|
38
38
|
Attributes
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
----------
|
|
40
|
+
name
|
|
41
|
+
A name for this organizer.
|
|
42
|
+
meta
|
|
43
|
+
A dictionary of metadata needed by the calculator.
|
|
44
|
+
_calculators
|
|
45
|
+
A managed dictionary of Calculators, indexed by name.
|
|
46
|
+
_constraints
|
|
47
|
+
A set of constrained Parameters. Constraints can be
|
|
48
|
+
added using the 'constrain' methods.
|
|
49
|
+
_parameters
|
|
50
|
+
A managed OrderedDict of contained Parameters.
|
|
51
|
+
_parsets
|
|
52
|
+
A managed dictionary of ParameterSets.
|
|
53
|
+
_restraints
|
|
54
|
+
A set of Restraints. Restraints can be added using the
|
|
55
|
+
'restrain' or 'confine' methods.
|
|
56
|
+
_eqfactory
|
|
57
|
+
A diffpy.srfit.equation.builder.EquationFactory
|
|
58
|
+
instance that is used create Equations from string.
|
|
50
59
|
|
|
51
60
|
Operator Attributes
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
-------------------
|
|
62
|
+
args
|
|
63
|
+
List of Literal arguments
|
|
64
|
+
nin
|
|
65
|
+
Number of inputs (<1 means this is variable)
|
|
66
|
+
nout
|
|
67
|
+
Number of outputs (1)
|
|
68
|
+
operation
|
|
69
|
+
Function that performs the operation, self.__call__
|
|
70
|
+
symbol
|
|
71
|
+
Same as name
|
|
72
|
+
_value
|
|
73
|
+
The value of the Operator.
|
|
74
|
+
value
|
|
75
|
+
Property for 'getValue'.
|
|
59
76
|
|
|
60
77
|
Properties
|
|
61
|
-
|
|
62
|
-
|
|
78
|
+
----------
|
|
79
|
+
names
|
|
80
|
+
Variable names (read only). See getNames.
|
|
81
|
+
values
|
|
82
|
+
Variable values (read only). See getValues.
|
|
63
83
|
"""
|
|
64
84
|
|
|
65
85
|
# define abstract attributes from the Operator base.
|