diffpy.srfit 3.3.0rc2__tar.gz → 3.3.1rc0__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.3.0rc2 → diffpy_srfit-3.3.1rc0}/PKG-INFO +10 -27
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/README.rst +9 -26
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/pyproject.toml +1 -1
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/pdf/pdfparser.py +75 -1
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy.srfit.egg-info/PKG-INFO +10 -27
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy.srfit.egg-info/SOURCES.txt +4 -1
- diffpy_srfit-3.3.1rc0/src/diffpy.srfit.egg-info/entry_points.txt +2 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_constraint.py +10 -3
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_fitrecipe.py +114 -99
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_parameterset.py +22 -10
- diffpy_srfit-3.3.1rc0/tests/test_pdfcontribution.py +150 -0
- diffpy_srfit-3.3.1rc0/tests/test_pdfgenerator.py +92 -0
- diffpy_srfit-3.3.1rc0/tests/test_pdfparser.py +224 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_profile.py +87 -73
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_recipeorganizer.py +111 -0
- diffpy_srfit-3.3.1rc0/tests/testdata/nom-mno-neutron.gr +15 -0
- diffpy_srfit-3.3.0rc2/src/diffpy.srfit.egg-info/entry_points.txt +0 -2
- diffpy_srfit-3.3.0rc2/tests/test_pdf.py +0 -517
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/AUTHORS.rst +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/LICENSE.rst +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/LICENSE_DANSE.rst +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/MANIFEST.in +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/requirements/build.txt +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/requirements/conda.txt +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/requirements/docs.txt +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/requirements/pip.txt +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/requirements/tests.txt +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/setup.cfg +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/__init__.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/__init__.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/__init__.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/builder.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/equationmod.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/literals/__init__.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/literals/abcs.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/literals/argument.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/literals/literal.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/literals/operators.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/visitors/__init__.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/visitors/argfinder.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/visitors/printer.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/visitors/swapper.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/visitors/validator.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/equation/visitors/visitor.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/exceptions.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/__init__.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/calculator.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/configurable.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/constraint.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/fitcontribution.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/fithook.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/fitrecipe.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/fitresults.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/parameter.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/parameterset.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/profile.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/profilegenerator.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/profileparser.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/recipeorganizer.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/restraint.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/simplerecipe.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/fitbase/validatable.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/interface/__init__.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/interface/interface.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/pdf/__init__.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/pdf/basepdfgenerator.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/pdf/characteristicfunctions.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/pdf/debyepdfgenerator.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/pdf/pdfcontribution.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/pdf/pdfgenerator.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/sas/__init__.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/sas/prcalculator.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/sas/sasgenerator.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/sas/sasimport.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/sas/sasparameter.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/sas/sasparser.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/sas/sasprofile.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/srfit_app.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/structure/__init__.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/structure/basestructureparset.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/structure/bvsrestraint.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/structure/cctbxparset.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/structure/diffpyparset.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/structure/objcrystparset.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/structure/sgconstraints.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/structure/srrealparset.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/util/__init__.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/util/argbinders.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/util/inpututils.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/util/nameutils.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/util/observable.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/util/tagmanager.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/util/weakrefcallable.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy/srfit/version.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy.srfit.egg-info/dependency_links.txt +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy.srfit.egg-info/requires.txt +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/src/diffpy.srfit.egg-info/top_level.txt +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/__init__.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/conftest.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/debug.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/run.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_builder.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_characteristicfunctions.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_contribution.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_diffpyparset.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_equation.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_fitresults.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_literals.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_objcrystparset.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_parameter.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_profilegenerator.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_profileparser.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_restraint.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_sas.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_sgconstraints.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_speed.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_tagmanager.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_version.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_visitors.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/test_weakrefcallable.py +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/testdata/LaMnO3.stru +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/testdata/ni-q27r100-neutron.gr +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/testdata/ni.cif +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/testdata/results.res +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/testdata/sas_ascii_test_1.txt +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/testdata/sas_ellipsoid_testdata.txt +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/testdata/si-q27r60-xray.gr +0 -0
- {diffpy_srfit-3.3.0rc2 → diffpy_srfit-3.3.1rc0}/tests/testdata/testdata.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffpy.srfit
|
|
3
|
-
Version: 3.3.
|
|
3
|
+
Version: 3.3.1rc0
|
|
4
4
|
Summary: Generalized code base for modeling problems.
|
|
5
5
|
Author-email: Christopher Farrow <farrowch@gmail.com>, Pavol Juhas <pavol.juhas@gmail.com>, Caden Myers <cjm2304@columbia.edu>, "Simon J. L. Billinge" <sbillinge@ucsb.edu>
|
|
6
6
|
Maintainer-email: Caden Myers <cjm2304@columbia.edu>, "Simon J. L. Billinge" <sbillinge@ucsb.edu>
|
|
@@ -86,16 +86,16 @@ target function being optimized can be specified by the user according to the
|
|
|
86
86
|
data available.
|
|
87
87
|
|
|
88
88
|
Within the diffpy.srfit framework, any parameter used in describing the
|
|
89
|
-
|
|
89
|
+
model can be passed as a refinable variable to the global
|
|
90
90
|
optimizer. Once parameters are declared as variables they can easily be turned
|
|
91
91
|
"on" or "off", i.e. fixed or allowed to vary. Additionally, variables may be
|
|
92
92
|
constrained to obey mathematical relationships with other parameters or
|
|
93
|
-
variables used in the
|
|
93
|
+
variables used in the model. Restraints can be applied to
|
|
94
94
|
variables, which adds a penalty to the refinement process commensurate with the
|
|
95
95
|
deviation from the known value or range. The cost function can also be
|
|
96
|
-
customized by the user. If the refinement contains multiple models, each model
|
|
96
|
+
customized by the user. If the refinement contains multiple ``physics" models, each model
|
|
97
97
|
can have its own cost function which will be properly weighted and combined to
|
|
98
|
-
obtain the total cost function. Additionally, diffpy.srfit is designed to be
|
|
98
|
+
obtain the total cost function. Additionally, ``diffpy.srfit`` is designed to be
|
|
99
99
|
extensible, allowing the user to integrate external calculators to perform
|
|
100
100
|
co-refinements with other techniques.
|
|
101
101
|
|
|
@@ -134,7 +134,11 @@ If you use diffpy.srfit in a scientific publication, we would like you to cite t
|
|
|
134
134
|
Installation
|
|
135
135
|
------------
|
|
136
136
|
|
|
137
|
-
The
|
|
137
|
+
The best way to install ``diffpy.srfit`` is as part of the ``diffpy.cmi`` package. Please
|
|
138
|
+
see https://github.com/diffpy/diffpy.cmi for installation information.
|
|
139
|
+
|
|
140
|
+
If for some reason you want to install the ``diffpy.srfit`` library on its own,
|
|
141
|
+
the preferred method is to use `Miniconda Python
|
|
138
142
|
<https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html>`_
|
|
139
143
|
and install from the "conda-forge" channel of Conda packages.
|
|
140
144
|
|
|
@@ -150,27 +154,6 @@ The following creates and activates a new environment named ``diffpy.srfit_env``
|
|
|
150
154
|
|
|
151
155
|
The output should print the latest version displayed on the badges above.
|
|
152
156
|
|
|
153
|
-
This will install the minimal `diffpy.srfit` installation. It will often be used
|
|
154
|
-
as along with other packages for manipulating and computing crystal structures
|
|
155
|
-
and so on. We also therefore recommend installing the following:
|
|
156
|
-
|
|
157
|
-
* ``diffpy.structure`` - crystal structure container and parsers,
|
|
158
|
-
https://github.com/diffpy/diffpy.structure
|
|
159
|
-
* ``pyobjcryst`` - Crystal and Molecule storage, rigid units, bond
|
|
160
|
-
length and bond angle restraints, https://github.com/diffpy/pyobjcryst
|
|
161
|
-
|
|
162
|
-
Optimizations involving pair distribution functions PDF or bond valence
|
|
163
|
-
sums require
|
|
164
|
-
|
|
165
|
-
* ``diffpy.srreal`` - python library for PDF calculation,
|
|
166
|
-
https://github.com/diffpy/diffpy.srreal
|
|
167
|
-
|
|
168
|
-
Optimizations involving small angle scattering or shape characteristic
|
|
169
|
-
functions from the diffpy.srfit.sas module require
|
|
170
|
-
|
|
171
|
-
* ``sas`` - module for calculation of P(R) in small-angle scattering
|
|
172
|
-
from the SasView project, http://www.sasview.org
|
|
173
|
-
|
|
174
157
|
Fallback Installation
|
|
175
158
|
---------------------
|
|
176
159
|
|
|
@@ -50,16 +50,16 @@ target function being optimized can be specified by the user according to the
|
|
|
50
50
|
data available.
|
|
51
51
|
|
|
52
52
|
Within the diffpy.srfit framework, any parameter used in describing the
|
|
53
|
-
|
|
53
|
+
model can be passed as a refinable variable to the global
|
|
54
54
|
optimizer. Once parameters are declared as variables they can easily be turned
|
|
55
55
|
"on" or "off", i.e. fixed or allowed to vary. Additionally, variables may be
|
|
56
56
|
constrained to obey mathematical relationships with other parameters or
|
|
57
|
-
variables used in the
|
|
57
|
+
variables used in the model. Restraints can be applied to
|
|
58
58
|
variables, which adds a penalty to the refinement process commensurate with the
|
|
59
59
|
deviation from the known value or range. The cost function can also be
|
|
60
|
-
customized by the user. If the refinement contains multiple models, each model
|
|
60
|
+
customized by the user. If the refinement contains multiple ``physics" models, each model
|
|
61
61
|
can have its own cost function which will be properly weighted and combined to
|
|
62
|
-
obtain the total cost function. Additionally, diffpy.srfit is designed to be
|
|
62
|
+
obtain the total cost function. Additionally, ``diffpy.srfit`` is designed to be
|
|
63
63
|
extensible, allowing the user to integrate external calculators to perform
|
|
64
64
|
co-refinements with other techniques.
|
|
65
65
|
|
|
@@ -98,7 +98,11 @@ If you use diffpy.srfit in a scientific publication, we would like you to cite t
|
|
|
98
98
|
Installation
|
|
99
99
|
------------
|
|
100
100
|
|
|
101
|
-
The
|
|
101
|
+
The best way to install ``diffpy.srfit`` is as part of the ``diffpy.cmi`` package. Please
|
|
102
|
+
see https://github.com/diffpy/diffpy.cmi for installation information.
|
|
103
|
+
|
|
104
|
+
If for some reason you want to install the ``diffpy.srfit`` library on its own,
|
|
105
|
+
the preferred method is to use `Miniconda Python
|
|
102
106
|
<https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html>`_
|
|
103
107
|
and install from the "conda-forge" channel of Conda packages.
|
|
104
108
|
|
|
@@ -114,27 +118,6 @@ The following creates and activates a new environment named ``diffpy.srfit_env``
|
|
|
114
118
|
|
|
115
119
|
The output should print the latest version displayed on the badges above.
|
|
116
120
|
|
|
117
|
-
This will install the minimal `diffpy.srfit` installation. It will often be used
|
|
118
|
-
as along with other packages for manipulating and computing crystal structures
|
|
119
|
-
and so on. We also therefore recommend installing the following:
|
|
120
|
-
|
|
121
|
-
* ``diffpy.structure`` - crystal structure container and parsers,
|
|
122
|
-
https://github.com/diffpy/diffpy.structure
|
|
123
|
-
* ``pyobjcryst`` - Crystal and Molecule storage, rigid units, bond
|
|
124
|
-
length and bond angle restraints, https://github.com/diffpy/pyobjcryst
|
|
125
|
-
|
|
126
|
-
Optimizations involving pair distribution functions PDF or bond valence
|
|
127
|
-
sums require
|
|
128
|
-
|
|
129
|
-
* ``diffpy.srreal`` - python library for PDF calculation,
|
|
130
|
-
https://github.com/diffpy/diffpy.srreal
|
|
131
|
-
|
|
132
|
-
Optimizations involving small angle scattering or shape characteristic
|
|
133
|
-
functions from the diffpy.srfit.sas module require
|
|
134
|
-
|
|
135
|
-
* ``sas`` - module for calculation of P(R) in small-angle scattering
|
|
136
|
-
from the SasView project, http://www.sasview.org
|
|
137
|
-
|
|
138
121
|
Fallback Installation
|
|
139
122
|
---------------------
|
|
140
123
|
|
|
@@ -53,7 +53,7 @@ exclude = [] # exclude packages matching these glob patterns (empty by default)
|
|
|
53
53
|
namespaces = false # to disable scanning PEP 420 namespaces (true by default)
|
|
54
54
|
|
|
55
55
|
[project.scripts]
|
|
56
|
-
diffpy-srfit = "diffpy.srfit.
|
|
56
|
+
diffpy-srfit = "diffpy.srfit.srfit_app:main"
|
|
57
57
|
|
|
58
58
|
[tool.setuptools.dynamic]
|
|
59
59
|
dependencies = {file = ["requirements/pip.txt"]}
|
|
@@ -22,8 +22,13 @@ See the class documentation for more information.
|
|
|
22
22
|
|
|
23
23
|
__all__ = ["PDFParser"]
|
|
24
24
|
|
|
25
|
+
import re
|
|
26
|
+
from pathlib import Path
|
|
27
|
+
|
|
25
28
|
from diffpy.srfit.fitbase.profileparser import ProfileParser
|
|
26
29
|
|
|
30
|
+
_FLOAT_RX = r"[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?"
|
|
31
|
+
|
|
27
32
|
|
|
28
33
|
class PDFParser(ProfileParser):
|
|
29
34
|
"""Parser for PDF diffraction pattern data.
|
|
@@ -31,7 +36,11 @@ class PDFParser(ProfileParser):
|
|
|
31
36
|
PDFgetX and PDFgetN write their header as plain ``name = value``
|
|
32
37
|
pairs, including ``stype = X`` or ``stype = N`` for the scattering
|
|
33
38
|
type, so this class parses files identically to ``ProfileParser``
|
|
34
|
-
|
|
39
|
+
for those. Some facilities instead prepend a
|
|
40
|
+
free-text instrument comment, so this class also falls back to
|
|
41
|
+
scanning that comment for the scattering type, ``qmin``, ``qmax``,
|
|
42
|
+
``qdamp``, and ``qbroad`` when they are not already present as
|
|
43
|
+
``name = value`` pairs.
|
|
35
44
|
|
|
36
45
|
Attributes
|
|
37
46
|
----------
|
|
@@ -85,6 +94,10 @@ class PDFParser(ProfileParser):
|
|
|
85
94
|
The minimum scattering vector (float).
|
|
86
95
|
qmax
|
|
87
96
|
The maximum scattering vector (float).
|
|
97
|
+
qdamp
|
|
98
|
+
The Q-resolution damping factor (float).
|
|
99
|
+
qbroad
|
|
100
|
+
The Q-resolution broadening factor (float).
|
|
88
101
|
|
|
89
102
|
These, along with any other ``name = value`` pairs in the header,
|
|
90
103
|
may appear in the metadata dictionary.
|
|
@@ -92,5 +105,66 @@ class PDFParser(ProfileParser):
|
|
|
92
105
|
|
|
93
106
|
_format = "PDF"
|
|
94
107
|
|
|
108
|
+
def _parse_metadata(self, filename):
|
|
109
|
+
"""Return the metadata read from a PDFgetX or PDFgetN header.
|
|
110
|
+
|
|
111
|
+
This calls ``ProfileParser``'s ``name = value`` based parsing
|
|
112
|
+
first, then falls back to scanning the free-text instrument
|
|
113
|
+
comments some facilities prepend to their files for the
|
|
114
|
+
scattering type and Q-resolution parameters that
|
|
115
|
+
such comments are not already covered by a ``name = value``
|
|
116
|
+
pair.
|
|
117
|
+
|
|
118
|
+
Parameters
|
|
119
|
+
----------
|
|
120
|
+
filename : str or Path
|
|
121
|
+
The name of the file to parse.
|
|
122
|
+
|
|
123
|
+
Returns
|
|
124
|
+
-------
|
|
125
|
+
dict
|
|
126
|
+
The metadata read from the file header.
|
|
127
|
+
"""
|
|
128
|
+
metadata = super()._parse_metadata(filename)
|
|
129
|
+
self._parse_comment_metadata(Path(filename).read_text(), metadata)
|
|
130
|
+
return metadata
|
|
131
|
+
|
|
132
|
+
@staticmethod
|
|
133
|
+
def _parse_comment_metadata(header_text, metadata):
|
|
134
|
+
"""Fill in stype, qmin, qmax, qdamp, and qbroad from free-text
|
|
135
|
+
instrument comments, without overwriting values already found
|
|
136
|
+
by the ``name = value`` based parsing.
|
|
137
|
+
|
|
138
|
+
Parameters
|
|
139
|
+
----------
|
|
140
|
+
header_text : str
|
|
141
|
+
The full text of the file being parsed.
|
|
142
|
+
meta : dict
|
|
143
|
+
The metadata dictionary to update in place.
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
dict
|
|
148
|
+
The updated metadata dictionary.
|
|
149
|
+
"""
|
|
150
|
+
if "stype" not in metadata:
|
|
151
|
+
if re.search(r"(x-?ray|PDFgetX)", header_text, re.I):
|
|
152
|
+
metadata["stype"] = "X"
|
|
153
|
+
elif re.search(r"(neutron|PDFgetN)", header_text, re.I):
|
|
154
|
+
metadata["stype"] = "N"
|
|
155
|
+
regexes = {
|
|
156
|
+
"qmin": r"\bqmin *= *(%s)\b" % _FLOAT_RX,
|
|
157
|
+
"qmax": r"\bqmax *= *(%s)\b" % _FLOAT_RX,
|
|
158
|
+
"qdamp": r"\b(?:qdamp|qsig) *= *(%s)\b" % _FLOAT_RX,
|
|
159
|
+
"qbroad": r"\b(?:qbroad|qalp) *= *(%s)\b" % _FLOAT_RX,
|
|
160
|
+
}
|
|
161
|
+
for key, pattern in regexes.items():
|
|
162
|
+
if key in metadata:
|
|
163
|
+
continue
|
|
164
|
+
res = re.search(pattern, header_text, re.I)
|
|
165
|
+
if res:
|
|
166
|
+
metadata[key] = float(res.group(1))
|
|
167
|
+
return metadata
|
|
168
|
+
|
|
95
169
|
|
|
96
170
|
# End of PDFParser
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffpy.srfit
|
|
3
|
-
Version: 3.3.
|
|
3
|
+
Version: 3.3.1rc0
|
|
4
4
|
Summary: Generalized code base for modeling problems.
|
|
5
5
|
Author-email: Christopher Farrow <farrowch@gmail.com>, Pavol Juhas <pavol.juhas@gmail.com>, Caden Myers <cjm2304@columbia.edu>, "Simon J. L. Billinge" <sbillinge@ucsb.edu>
|
|
6
6
|
Maintainer-email: Caden Myers <cjm2304@columbia.edu>, "Simon J. L. Billinge" <sbillinge@ucsb.edu>
|
|
@@ -86,16 +86,16 @@ target function being optimized can be specified by the user according to the
|
|
|
86
86
|
data available.
|
|
87
87
|
|
|
88
88
|
Within the diffpy.srfit framework, any parameter used in describing the
|
|
89
|
-
|
|
89
|
+
model can be passed as a refinable variable to the global
|
|
90
90
|
optimizer. Once parameters are declared as variables they can easily be turned
|
|
91
91
|
"on" or "off", i.e. fixed or allowed to vary. Additionally, variables may be
|
|
92
92
|
constrained to obey mathematical relationships with other parameters or
|
|
93
|
-
variables used in the
|
|
93
|
+
variables used in the model. Restraints can be applied to
|
|
94
94
|
variables, which adds a penalty to the refinement process commensurate with the
|
|
95
95
|
deviation from the known value or range. The cost function can also be
|
|
96
|
-
customized by the user. If the refinement contains multiple models, each model
|
|
96
|
+
customized by the user. If the refinement contains multiple ``physics" models, each model
|
|
97
97
|
can have its own cost function which will be properly weighted and combined to
|
|
98
|
-
obtain the total cost function. Additionally, diffpy.srfit is designed to be
|
|
98
|
+
obtain the total cost function. Additionally, ``diffpy.srfit`` is designed to be
|
|
99
99
|
extensible, allowing the user to integrate external calculators to perform
|
|
100
100
|
co-refinements with other techniques.
|
|
101
101
|
|
|
@@ -134,7 +134,11 @@ If you use diffpy.srfit in a scientific publication, we would like you to cite t
|
|
|
134
134
|
Installation
|
|
135
135
|
------------
|
|
136
136
|
|
|
137
|
-
The
|
|
137
|
+
The best way to install ``diffpy.srfit`` is as part of the ``diffpy.cmi`` package. Please
|
|
138
|
+
see https://github.com/diffpy/diffpy.cmi for installation information.
|
|
139
|
+
|
|
140
|
+
If for some reason you want to install the ``diffpy.srfit`` library on its own,
|
|
141
|
+
the preferred method is to use `Miniconda Python
|
|
138
142
|
<https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html>`_
|
|
139
143
|
and install from the "conda-forge" channel of Conda packages.
|
|
140
144
|
|
|
@@ -150,27 +154,6 @@ The following creates and activates a new environment named ``diffpy.srfit_env``
|
|
|
150
154
|
|
|
151
155
|
The output should print the latest version displayed on the badges above.
|
|
152
156
|
|
|
153
|
-
This will install the minimal `diffpy.srfit` installation. It will often be used
|
|
154
|
-
as along with other packages for manipulating and computing crystal structures
|
|
155
|
-
and so on. We also therefore recommend installing the following:
|
|
156
|
-
|
|
157
|
-
* ``diffpy.structure`` - crystal structure container and parsers,
|
|
158
|
-
https://github.com/diffpy/diffpy.structure
|
|
159
|
-
* ``pyobjcryst`` - Crystal and Molecule storage, rigid units, bond
|
|
160
|
-
length and bond angle restraints, https://github.com/diffpy/pyobjcryst
|
|
161
|
-
|
|
162
|
-
Optimizations involving pair distribution functions PDF or bond valence
|
|
163
|
-
sums require
|
|
164
|
-
|
|
165
|
-
* ``diffpy.srreal`` - python library for PDF calculation,
|
|
166
|
-
https://github.com/diffpy/diffpy.srreal
|
|
167
|
-
|
|
168
|
-
Optimizations involving small angle scattering or shape characteristic
|
|
169
|
-
functions from the diffpy.srfit.sas module require
|
|
170
|
-
|
|
171
|
-
* ``sas`` - module for calculation of P(R) in small-angle scattering
|
|
172
|
-
from the SasView project, http://www.sasview.org
|
|
173
|
-
|
|
174
157
|
Fallback Installation
|
|
175
158
|
---------------------
|
|
176
159
|
|
|
@@ -98,7 +98,9 @@ tests/test_literals.py
|
|
|
98
98
|
tests/test_objcrystparset.py
|
|
99
99
|
tests/test_parameter.py
|
|
100
100
|
tests/test_parameterset.py
|
|
101
|
-
tests/
|
|
101
|
+
tests/test_pdfcontribution.py
|
|
102
|
+
tests/test_pdfgenerator.py
|
|
103
|
+
tests/test_pdfparser.py
|
|
102
104
|
tests/test_profile.py
|
|
103
105
|
tests/test_profilegenerator.py
|
|
104
106
|
tests/test_profileparser.py
|
|
@@ -114,6 +116,7 @@ tests/test_weakrefcallable.py
|
|
|
114
116
|
tests/testdata/LaMnO3.stru
|
|
115
117
|
tests/testdata/ni-q27r100-neutron.gr
|
|
116
118
|
tests/testdata/ni.cif
|
|
119
|
+
tests/testdata/nom-mno-neutron.gr
|
|
117
120
|
tests/testdata/results.res
|
|
118
121
|
tests/testdata/sas_ascii_test_1.txt
|
|
119
122
|
tests/testdata/sas_ellipsoid_testdata.txt
|
|
@@ -60,10 +60,17 @@ class TestConstraint(unittest.TestCase):
|
|
|
60
60
|
return
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
# ----------------------------------------------------------------------------
|
|
64
|
+
# Constraint.constrain and Parameter.setConst are deprecated in favor of
|
|
65
|
+
# Constraint.add_constraint and Parameter.set_constant. The old names must
|
|
66
|
+
# still work and forward to the new implementation.
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
|
|
69
|
+
class TestConstraintDeprecated(unittest.TestCase):
|
|
70
|
+
|
|
71
|
+
def test_constrain_deprecated(self):
|
|
72
|
+
"""Test the deprecated Constraint.constrain and
|
|
73
|
+
Parameter.setConst methods."""
|
|
67
74
|
p1 = Parameter("p1", 1)
|
|
68
75
|
p2 = Parameter("p2", 2)
|
|
69
76
|
|
|
@@ -340,62 +340,6 @@ def test_convert_bounds_to_restraints():
|
|
|
340
340
|
assert r.scaled is True
|
|
341
341
|
|
|
342
342
|
|
|
343
|
-
def testPrintFitHook(capturestdout):
|
|
344
|
-
"check output from default PrintFitHook."
|
|
345
|
-
recipe = FitRecipe("recipe")
|
|
346
|
-
recipe.fithooks[0].verbose = 0
|
|
347
|
-
|
|
348
|
-
# Set up the Profile
|
|
349
|
-
profile = Profile()
|
|
350
|
-
x = linspace(0, pi, 10)
|
|
351
|
-
y = sin(x)
|
|
352
|
-
profile.set_observed_profile(x, y)
|
|
353
|
-
|
|
354
|
-
# Set up the FitContribution
|
|
355
|
-
fitcontribution = FitContribution("cont")
|
|
356
|
-
fitcontribution.set_profile(profile)
|
|
357
|
-
fitcontribution.set_equation("A*sin(k*x + c)")
|
|
358
|
-
fitcontribution.A.set_value(1)
|
|
359
|
-
fitcontribution.k.set_value(1)
|
|
360
|
-
fitcontribution.c.set_value(0)
|
|
361
|
-
|
|
362
|
-
recipe.addContribution(fitcontribution)
|
|
363
|
-
|
|
364
|
-
recipe.add_variable(fitcontribution.c)
|
|
365
|
-
recipe.add_soft_bounds("c", lower_bound=5)
|
|
366
|
-
(pfh,) = recipe.getFitHooks()
|
|
367
|
-
out = capturestdout(recipe.scalar_residual)
|
|
368
|
-
assert "" == out
|
|
369
|
-
pfh.verbose = 1
|
|
370
|
-
out = capturestdout(recipe.scalar_residual)
|
|
371
|
-
assert out.strip().isdigit()
|
|
372
|
-
assert "\nRestraints:" not in out
|
|
373
|
-
pfh.verbose = 2
|
|
374
|
-
out = capturestdout(recipe.scalar_residual)
|
|
375
|
-
assert "\nResidual:" in out
|
|
376
|
-
assert "\nRestraints:" in out
|
|
377
|
-
assert "\nVariables" not in out
|
|
378
|
-
pfh.verbose = 3
|
|
379
|
-
out = capturestdout(recipe.scalarResidual)
|
|
380
|
-
assert "\nVariables" in out
|
|
381
|
-
assert "c = " in out
|
|
382
|
-
return
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
def test_add_and_remove_ParameterSet():
|
|
386
|
-
# add a parset
|
|
387
|
-
recipe = FitRecipe("recipe")
|
|
388
|
-
parameter_to_add = Parameter("added_param", 1)
|
|
389
|
-
recipe.addParameterSet(parameter_to_add)
|
|
390
|
-
# check that the parameter is added
|
|
391
|
-
assert recipe.added_param == parameter_to_add
|
|
392
|
-
assert recipe.added_param.value == 1
|
|
393
|
-
# remove the added parameter
|
|
394
|
-
recipe.removeParameterSet(parameter_to_add)
|
|
395
|
-
# check that the parameter is removed
|
|
396
|
-
assert not hasattr(recipe, "added_param")
|
|
397
|
-
|
|
398
|
-
|
|
399
343
|
def test_add_and_remove_parameter_set():
|
|
400
344
|
recipe = FitRecipe("recipe")
|
|
401
345
|
parameter_to_add = Parameter("added_param", 1)
|
|
@@ -411,12 +355,12 @@ def test_add_and_remove_parameter_set():
|
|
|
411
355
|
|
|
412
356
|
|
|
413
357
|
def test_add_contribution(capturestdout):
|
|
414
|
-
"""
|
|
415
|
-
has changed to the new add_contribution method. This is because
|
|
416
|
-
addContribution is deprecated.
|
|
358
|
+
"""Check output from default PrintFitHook using add_contribution.
|
|
417
359
|
|
|
418
|
-
|
|
419
|
-
|
|
360
|
+
Covers the same behavior as test_print_fit_hook_deprecated (see the
|
|
361
|
+
deprecated-API section at the bottom of this file), which uses the
|
|
362
|
+
deprecated addContribution instead. Once addContribution is removed
|
|
363
|
+
in 4.0.0, delete that test and keep this one.
|
|
420
364
|
"""
|
|
421
365
|
recipe = FitRecipe("recipe")
|
|
422
366
|
recipe.fithooks[0].verbose = 0
|
|
@@ -668,27 +612,6 @@ def build_recipe_from_datafile(datafile):
|
|
|
668
612
|
return recipe
|
|
669
613
|
|
|
670
614
|
|
|
671
|
-
def build_recipe_from_datafile_deprecated(datafile):
|
|
672
|
-
"""Duplicate of build_recipe_from_datafile to use deprecated
|
|
673
|
-
loadParsedData method.
|
|
674
|
-
|
|
675
|
-
Remove in version 4.0.0.
|
|
676
|
-
"""
|
|
677
|
-
profile = Profile()
|
|
678
|
-
parser = PDFParser()
|
|
679
|
-
parser.parseFile(str(datafile))
|
|
680
|
-
profile.loadParsedData(parser)
|
|
681
|
-
|
|
682
|
-
contribution = FitContribution("c")
|
|
683
|
-
contribution.set_profile(profile)
|
|
684
|
-
contribution.set_equation("m*x + b")
|
|
685
|
-
recipe = FitRecipe()
|
|
686
|
-
recipe.add_contribution(contribution)
|
|
687
|
-
recipe.add_variable(contribution.m, 1)
|
|
688
|
-
recipe.add_variable(contribution.b, 0)
|
|
689
|
-
return recipe
|
|
690
|
-
|
|
691
|
-
|
|
692
615
|
def test_plot_recipe_bad_display(build_recipes_one_contribution):
|
|
693
616
|
recipe, _ = build_recipes_one_contribution
|
|
694
617
|
# Case: All plots are disabled
|
|
@@ -1043,23 +966,6 @@ def test_plot_recipe_labels_from_gr_file_overwrite(temp_data_files):
|
|
|
1043
966
|
assert actual_ylabel == expected_ylabel
|
|
1044
967
|
|
|
1045
968
|
|
|
1046
|
-
def test_plot_recipe_labels_from_gr_file_overwrite_deprecated(temp_data_files):
|
|
1047
|
-
"Remove this test with version 4.0.0."
|
|
1048
|
-
gr_file = temp_data_files / "gr_file.gr"
|
|
1049
|
-
recipe = build_recipe_from_datafile_deprecated(gr_file)
|
|
1050
|
-
optimize_recipe(recipe)
|
|
1051
|
-
plt.close("all")
|
|
1052
|
-
fig, ax = recipe.plot_recipe(
|
|
1053
|
-
return_fig=True, show=False, xlabel="My X", ylabel="My Y"
|
|
1054
|
-
)
|
|
1055
|
-
actual_xlabel = ax.get_xlabel()
|
|
1056
|
-
actual_ylabel = ax.get_ylabel()
|
|
1057
|
-
expected_xlabel = "My X"
|
|
1058
|
-
expected_ylabel = "My Y"
|
|
1059
|
-
assert actual_xlabel == expected_xlabel
|
|
1060
|
-
assert actual_ylabel == expected_ylabel
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
969
|
def test_plot_recipe_reset_all_defaults(build_recipes_one_contribution):
|
|
1064
970
|
expected_defaults = {
|
|
1065
971
|
"show_observed": True,
|
|
@@ -1229,5 +1135,114 @@ def test_residual_is_weighted_by_uncertainty(
|
|
|
1229
1135
|
assert actual_residual == pytest.approx(expected_residual)
|
|
1230
1136
|
|
|
1231
1137
|
|
|
1138
|
+
# ----------------------------------------------------------------------------
|
|
1139
|
+
# addContribution, addParameterSet/removeParameterSet, and
|
|
1140
|
+
# PDFParser.parseFile/Profile.loadParsedData are deprecated in favor of
|
|
1141
|
+
# add_contribution, add_parameter_set/remove_parameter_set, and
|
|
1142
|
+
# PDFParser.parse_file/Profile.load_parsed_data. The old names must still
|
|
1143
|
+
# work and forward to the new implementation.
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
def test_print_fit_hook_deprecated(capturestdout):
|
|
1147
|
+
"""Check output from default PrintFitHook using the deprecated
|
|
1148
|
+
addContribution, getFitHooks, and scalarResidual methods.
|
|
1149
|
+
|
|
1150
|
+
Remove this test after addContribution is removed in 4.0.0; see
|
|
1151
|
+
test_add_contribution for the permanent replacement.
|
|
1152
|
+
"""
|
|
1153
|
+
recipe = FitRecipe("recipe")
|
|
1154
|
+
recipe.fithooks[0].verbose = 0
|
|
1155
|
+
|
|
1156
|
+
# Set up the Profile
|
|
1157
|
+
profile = Profile()
|
|
1158
|
+
x = linspace(0, pi, 10)
|
|
1159
|
+
y = sin(x)
|
|
1160
|
+
profile.set_observed_profile(x, y)
|
|
1161
|
+
|
|
1162
|
+
# Set up the FitContribution
|
|
1163
|
+
fitcontribution = FitContribution("cont")
|
|
1164
|
+
fitcontribution.set_profile(profile)
|
|
1165
|
+
fitcontribution.set_equation("A*sin(k*x + c)")
|
|
1166
|
+
fitcontribution.A.set_value(1)
|
|
1167
|
+
fitcontribution.k.set_value(1)
|
|
1168
|
+
fitcontribution.c.set_value(0)
|
|
1169
|
+
|
|
1170
|
+
recipe.addContribution(fitcontribution)
|
|
1171
|
+
|
|
1172
|
+
recipe.add_variable(fitcontribution.c)
|
|
1173
|
+
recipe.add_soft_bounds("c", lower_bound=5)
|
|
1174
|
+
(pfh,) = recipe.getFitHooks()
|
|
1175
|
+
out = capturestdout(recipe.scalar_residual)
|
|
1176
|
+
assert "" == out
|
|
1177
|
+
pfh.verbose = 1
|
|
1178
|
+
out = capturestdout(recipe.scalar_residual)
|
|
1179
|
+
assert out.strip().isdigit()
|
|
1180
|
+
assert "\nRestraints:" not in out
|
|
1181
|
+
pfh.verbose = 2
|
|
1182
|
+
out = capturestdout(recipe.scalar_residual)
|
|
1183
|
+
assert "\nResidual:" in out
|
|
1184
|
+
assert "\nRestraints:" in out
|
|
1185
|
+
assert "\nVariables" not in out
|
|
1186
|
+
pfh.verbose = 3
|
|
1187
|
+
out = capturestdout(recipe.scalarResidual)
|
|
1188
|
+
assert "\nVariables" in out
|
|
1189
|
+
assert "c = " in out
|
|
1190
|
+
return
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
def test_add_and_remove_parameter_set_deprecated():
|
|
1194
|
+
"""Test the deprecated addParameterSet and removeParameterSet
|
|
1195
|
+
methods."""
|
|
1196
|
+
recipe = FitRecipe("recipe")
|
|
1197
|
+
parameter_to_add = Parameter("added_param", 1)
|
|
1198
|
+
# add a parset
|
|
1199
|
+
recipe.addParameterSet(parameter_to_add)
|
|
1200
|
+
# check that the parameter is added
|
|
1201
|
+
assert recipe.added_param == parameter_to_add
|
|
1202
|
+
assert recipe.added_param.value == 1
|
|
1203
|
+
# remove the added parameter
|
|
1204
|
+
recipe.removeParameterSet(parameter_to_add)
|
|
1205
|
+
# check that the parameter is removed
|
|
1206
|
+
assert not hasattr(recipe, "added_param")
|
|
1207
|
+
|
|
1208
|
+
|
|
1209
|
+
def build_recipe_from_datafile_deprecated(datafile):
|
|
1210
|
+
"""Duplicate of build_recipe_from_datafile to use the deprecated
|
|
1211
|
+
PDFParser.parseFile and Profile.loadParsedData methods.
|
|
1212
|
+
|
|
1213
|
+
Remove in version 4.0.0.
|
|
1214
|
+
"""
|
|
1215
|
+
profile = Profile()
|
|
1216
|
+
parser = PDFParser()
|
|
1217
|
+
parser.parseFile(str(datafile))
|
|
1218
|
+
profile.loadParsedData(parser)
|
|
1219
|
+
|
|
1220
|
+
contribution = FitContribution("c")
|
|
1221
|
+
contribution.set_profile(profile)
|
|
1222
|
+
contribution.set_equation("m*x + b")
|
|
1223
|
+
recipe = FitRecipe()
|
|
1224
|
+
recipe.add_contribution(contribution)
|
|
1225
|
+
recipe.add_variable(contribution.m, 1)
|
|
1226
|
+
recipe.add_variable(contribution.b, 0)
|
|
1227
|
+
return recipe
|
|
1228
|
+
|
|
1229
|
+
|
|
1230
|
+
def test_plot_recipe_labels_from_gr_file_overwrite_deprecated(temp_data_files):
|
|
1231
|
+
"Remove this test with version 4.0.0."
|
|
1232
|
+
gr_file = temp_data_files / "gr_file.gr"
|
|
1233
|
+
recipe = build_recipe_from_datafile_deprecated(gr_file)
|
|
1234
|
+
optimize_recipe(recipe)
|
|
1235
|
+
plt.close("all")
|
|
1236
|
+
fig, ax = recipe.plot_recipe(
|
|
1237
|
+
return_fig=True, show=False, xlabel="My X", ylabel="My Y"
|
|
1238
|
+
)
|
|
1239
|
+
actual_xlabel = ax.get_xlabel()
|
|
1240
|
+
actual_ylabel = ax.get_ylabel()
|
|
1241
|
+
expected_xlabel = "My X"
|
|
1242
|
+
expected_ylabel = "My Y"
|
|
1243
|
+
assert actual_xlabel == expected_xlabel
|
|
1244
|
+
assert actual_ylabel == expected_ylabel
|
|
1245
|
+
|
|
1246
|
+
|
|
1232
1247
|
if __name__ == "__main__":
|
|
1233
1248
|
unittest.main()
|
|
@@ -26,16 +26,12 @@ class TestParameterSet(unittest.TestCase):
|
|
|
26
26
|
self.parset = ParameterSet("test")
|
|
27
27
|
return
|
|
28
28
|
|
|
29
|
-
def
|
|
30
|
-
"""Test the
|
|
31
|
-
|
|
32
|
-
Remove this test after the addParameterSet is removed in version
|
|
33
|
-
4.0.0.
|
|
34
|
-
"""
|
|
29
|
+
def test_add_parameter_set(self):
|
|
30
|
+
"""Test the add_parameter_set method."""
|
|
35
31
|
parset2 = ParameterSet("parset2")
|
|
36
32
|
p1 = Parameter("parset2", 1)
|
|
37
33
|
|
|
38
|
-
self.parset.
|
|
34
|
+
self.parset.add_parameter_set(parset2)
|
|
39
35
|
self.assertTrue(self.parset.parset2 is parset2)
|
|
40
36
|
|
|
41
37
|
self.assertRaises(ValueError, self.parset.add_parameter_set, p1)
|
|
@@ -47,12 +43,28 @@ class TestParameterSet(unittest.TestCase):
|
|
|
47
43
|
|
|
48
44
|
return
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
|
|
47
|
+
# ----------------------------------------------------------------------------
|
|
48
|
+
# addParameterSet is deprecated in favor of add_parameter_set. The old name
|
|
49
|
+
# must still work and forward to the new implementation.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class TestParameterSetDeprecated(unittest.TestCase):
|
|
53
|
+
|
|
54
|
+
def setUp(self):
|
|
55
|
+
self.parset = ParameterSet("test")
|
|
56
|
+
return
|
|
57
|
+
|
|
58
|
+
def test_add_parameter_set_deprecated(self):
|
|
59
|
+
"""Test the deprecated addParameterSet method.
|
|
60
|
+
|
|
61
|
+
Remove this test after the addParameterSet is removed in version
|
|
62
|
+
4.0.0.
|
|
63
|
+
"""
|
|
52
64
|
parset2 = ParameterSet("parset2")
|
|
53
65
|
p1 = Parameter("parset2", 1)
|
|
54
66
|
|
|
55
|
-
self.parset.
|
|
67
|
+
self.parset.addParameterSet(parset2)
|
|
56
68
|
self.assertTrue(self.parset.parset2 is parset2)
|
|
57
69
|
|
|
58
70
|
self.assertRaises(ValueError, self.parset.add_parameter_set, p1)
|