From a82aac7e0890d1ce4efe33b6b65faa46947db72a Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 30 Jun 2026 16:48:58 -0400 Subject: [PATCH 1/8] sync pre-commit file and pyproject.toml with main --- .pre-commit-config.yaml | 7 +++---- pyproject.toml | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d118bebc..c424bcf7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: - id: check-toml - id: check-added-large-files - repo: https://github.com/psf/black - rev: 26.3.1 + rev: 26.5.1 hooks: - id: black - repo: https://github.com/pycqa/flake8 @@ -29,7 +29,7 @@ repos: hooks: - id: flake8 - repo: https://github.com/pycqa/isort - rev: 8.0.1 + rev: 9.0.0a3 hooks: - id: isort args: ["--profile", "black"] @@ -59,9 +59,8 @@ repos: - "prettier@^3.2.4" # docformatter - PEP 257 compliant docstring formatter - repo: https://github.com/PyCQA/docformatter - rev: v1.7.7 + rev: v1.7.8 hooks: - id: docformatter - language_version: python3.13 additional_dependencies: [tomli] args: [--in-place, --config, ./pyproject.toml] diff --git a/pyproject.toml b/pyproject.toml index 677cc175..622b574d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ maintainers = [ description = "Generalized code base for modeling problems." keywords = ['regression', 'modeling', 'fitting', 'diffraction', 'PDF'] readme = "README.rst" -requires-python = ">=3.11, <3.14" +requires-python = ">=3.12, <3.15" classifiers = [ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', @@ -29,9 +29,9 @@ classifiers = [ 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX', 'Operating System :: Unix', - 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', 'Programming Language :: Python :: 3.13', + 'Programming Language :: Python :: 3.14', 'Topic :: Scientific/Engineering :: Physics', 'Topic :: Scientific/Engineering :: Chemistry', ] From 3bc23c4e5ec593b71ac087928d467d6f6eb25c62 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 30 Jun 2026 16:51:40 -0400 Subject: [PATCH 2/8] refactor pytest fixtures to remove use of triple quotes --- tests/conftest.py | 258 +++++++++++++++++++++++++++------------------- 1 file changed, 151 insertions(+), 107 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 23b92f6a..6677abb0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -228,136 +228,180 @@ def build_recipe_two_contributions(): def temp_data_files(tmp_path): """ Temporary directory containing: - - data_with_meta.gr - - data_without_meta.dat - Each file contains a single line of data. + - gr_file.gr + - dat_file.dat + - cgr_file.cgr + - fit_results.res """ - file_with_meta = tmp_path / "gr_file.gr" - file_with_meta.write_text("1.0 2.0\n" "1.1 2.1\n" "1.2 2.2\n") - - dat_file = tmp_path / "dat_file.dat" - dat_file.write_text("1.0 2.0\n" "1.1 2.1\n" "1.2 2.2\n") - - cgr_file = tmp_path / "cgr_file.cgr" - cgr_file.write_text("1.0 2.0\n" "1.1 2.1\n" "1.2 2.2\n") - - results_file = tmp_path / "fit_results.res" - results_file.write_text(""" -Results written: Wed Feb 25 15:14:58 2026 -produced by cadenmyers - -Some quantities invalid due to missing profile uncertainty -Overall (Chi2 and Reduced Chi2 invalid) ------------------------------------------------------------------------------- -Residual 0.00000000 -Contributions 0.00000000 -Restraints 0.00000000 -Chi2 0.00000000 -Reduced Chi2 0.00000000 -Rw 0.00000000 - -Variables (Uncertainties invalid) ------------------------------------------------------------------------------- -amplitude 1.00000000e+00 +/- 4.82804000e-01 -phase_shift -1.61291146e-18 +/- 1.00000000e+00 -wave_number 1.00000000e+00 +/- 2.17496687e-01 - -Variable Correlations greater than 25% (Correlations invalid) ------------------------------------------------------------------------------- -No correlations greater than 25% -""") + data = "\n".join( + [ + "1.0 2.0", + "1.1 2.1", + "1.2 2.2", + "", + ] + ) + + (tmp_path / "gr_file.gr").write_text(data) + (tmp_path / "dat_file.dat").write_text(data) + (tmp_path / "cgr_file.cgr").write_text(data) + + results = "\n".join( + [ + "Results written: Wed Feb 25 15:14:58 2026", + "produced by cadenmyers", + "", + "Some quantities invalid due to missing profile uncertainty", + "Overall (Chi2 and Reduced Chi2 invalid)", + "------------------------------------------------------------------------------", # noqa + "Residual 0.00000000", + "Contributions 0.00000000", + "Restraints 0.00000000", + "Chi2 0.00000000", + "Reduced Chi2 0.00000000", + "Rw 0.00000000", + "", + "Variables (Uncertainties invalid)", + "------------------------------------------------------------------------------", # noqa + "amplitude 1.00000000e+00 +/- 4.82804000e-01", + "phase_shift -1.61291146e-18 +/- 1.00000000e+00", + "wave_number 1.00000000e+00 +/- 2.17496687e-01", + "", + "Variable Correlations greater than 25% (Correlations invalid)", + "------------------------------------------------------------------------------", # noqa + "No correlations greater than 25%", + "", + ] + ) + + (tmp_path / "fit_results.res").write_text(results) + yield tmp_path @pytest.fixture def parser_datafiles(tmp_path): - """Create temporary data files with different column layouts and - yield the directory.""" - - METADATA_HEADER = r"""# xPDFsuite Configuration # -[PDF] -wavelength = 0.1 -dataformat = QA -inputfile = input.iq -backgroundfile = backgroundfile.iq -mode = xray -bgscale = 1.0 -composition = TiSe2 -outputtype = gr -qmaxinst = 25.0 -qmin = 0.1 -qmax = 25.0 -rmax = 140.0 -rmin = 0.0 -rstep = 0.01 -rpoly = 0.7 - -[Misc] -inputdir = /my/data/dir -savedir = /my/save/dir -backgroundfilefull = /my/data/dir/backgroundfile.iq - -#### start data -#S 1 -""" - - # Four-column standard + """Create temporary data files with different column layouts.""" + metadata = "\n".join( + [ + "# xPDFsuite Configuration #", + "[PDF]", + "wavelength = 0.1", + "dataformat = QA", + "inputfile = input.iq", + "backgroundfile = backgroundfile.iq", + "mode = xray", + "bgscale = 1.0", + "composition = TiSe2", + "outputtype = gr", + "qmaxinst = 25.0", + "qmin = 0.1", + "qmax = 25.0", + "rmax = 140.0", + "rmin = 0.0", + "rstep = 0.01", + "rpoly = 0.7", + "", + "[Misc]", + "inputdir = /my/data/dir", + "savedir = /my/save/dir", + "backgroundfilefull = /my/data/dir/backgroundfile.iq", + "", + "#### start data", + "#S 1", + "", + ] + ) + (tmp_path / "four_col.gr").write_text( - METADATA_HEADER - + r"""#L r($\AA$) G($\AA^{-2}$) dr($\AA$) dG($\AA^{-2}$) -1.0 2.0 0.1 0.2 -1.1 2.1 0.3 0.4 -1.2 2.2 0.5 0.6""" + metadata + + "\n".join( + [ + r"#L r($\AA$) G($\AA^{-2}$) dr($\AA$) dG($\AA^{-2}$)", + "1.0 2.0 0.1 0.2", + "1.1 2.1 0.3 0.4", + "1.2 2.2 0.5 0.6", + "", + ] + ) ) - # Three-column (x, y, dy) (tmp_path / "three_col.dat").write_text( - METADATA_HEADER + r"""#L r($\AA$) G($\AA^{-2}$) dG($\AA^{-2}$) -1.0 2.0 0.2 -1.1 2.1 0.4 -1.2 2.2 0.6""" + metadata + + "\n".join( + [ + r"#L r($\AA$) G($\AA^{-2}$) dG($\AA^{-2}$)", + "1.0 2.0 0.2", + "1.1 2.1 0.4", + "1.2 2.2 0.6", + "", + ] + ) ) - # Two-column (x, y) (tmp_path / "two_col.txt").write_text( - METADATA_HEADER + r"""#L r($\AA$) G($\AA^{-2}$) -1.0 2.0 -1.1 2.1 -1.2 2.2""" + metadata + + "\n".join( + [ + r"#L r($\AA$) G($\AA^{-2}$)", + "1.0 2.0", + "1.1 2.1", + "1.2 2.2", + "", + ] + ) ) - # Four-column reordered (x, dx, y, dy) (tmp_path / "four_col_reordered.txt").write_text( - METADATA_HEADER - + r"""#L r($\AA$) dr($\AA$) G($\AA^{-2}$) dG($\AA^{-2}$) -1.0 0.1 2.0 0.2 -1.1 0.3 2.1 0.4 -1.2 0.5 2.2 0.6""" + metadata + + "\n".join( + [ + r"#L r($\AA$) dr($\AA$) G($\AA^{-2}$) dG($\AA^{-2}$)", + "1.0 0.1 2.0 0.2", + "1.1 0.3 2.1 0.4", + "1.2 0.5 2.2 0.6", + "", + ] + ) ) - # Four-column with NaN/Inf (tmp_path / "four_col_nan_inf.gr").write_text( - METADATA_HEADER - + r"""#L r($\AA$) G($\AA^{-2}$) dr($\AA$) dG($\AA^{-2}$) -1.0 2.0 nan inf -1.1 2.1 inf 1 -1.2 2.2 nan nan""" + metadata + + "\n".join( + [ + r"#L r($\AA$) G($\AA^{-2}$) dr($\AA$) dG($\AA^{-2}$)", + "1.0 2.0 nan inf", + "1.1 2.1 inf 1", + "1.2 2.2 nan nan", + "", + ] + ) ) - # One-column - (tmp_path / "one_col.gr").write_text(METADATA_HEADER + r"""#L r($\AA$) -1.0 -1.1 -1.2""") + (tmp_path / "one_col.gr").write_text( + metadata + + "\n".join( + [ + r"#L r($\AA$)", + "1.0", + "1.1", + "1.2", + "", + ] + ) + ) - # Five-column (extra column) (tmp_path / "five_col.gr").write_text( - METADATA_HEADER - + r"""#L r($\AA$) G($\AA^{-2}$) dr($\AA$) dG($\AA^{-2}$) extra -1.0 2.0 0.1 0.2 9.9 -1.1 2.1 0.3 0.4 9.8 -1.2 2.2 0.5 0.6 9.7""" + metadata + + "\n".join( + [ + r"#L r($\AA$) G($\AA^{-2}$) dr($\AA$) dG($\AA^{-2}$) extra", + "1.0 2.0 0.1 0.2 9.9", + "1.1 2.1 0.3 0.4 9.8", + "1.2 2.2 0.5 0.6 9.7", + "", + ] + ) ) - # Yield the directory yield tmp_path From 4a475423682f239fc9b71b5a0d4df6f814f0a4f8 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 30 Jun 2026 16:52:37 -0400 Subject: [PATCH 3/8] chore: news --- news/sync-w-main-v1.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/sync-w-main-v1.rst diff --git a/news/sync-w-main-v1.rst b/news/sync-w-main-v1.rst new file mode 100644 index 00000000..ca16abf2 --- /dev/null +++ b/news/sync-w-main-v1.rst @@ -0,0 +1,23 @@ +**Added:** + +* No news needed: refactoring of pytest fixtures + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 501cd162a3db71f9492cb6f8bab634eb3b91dc04 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Jun 2026 20:55:45 +0000 Subject: [PATCH 4/8] [pre-commit.ci] auto fixes from pre-commit hooks --- docs/examples/coreshellnp.py | 3 --- docs/examples/crystalpdf.py | 2 -- docs/examples/crystalpdfall.py | 2 -- docs/examples/crystalpdfobjcryst.py | 1 - docs/examples/crystalpdftwodata.py | 2 -- docs/examples/crystalpdftwophase.py | 2 -- docs/examples/debyemodel.py | 3 --- docs/examples/debyemodelII.py | 2 -- docs/examples/ellipsoidsas.py | 2 -- docs/examples/gaussiangenerator.py | 1 - docs/examples/gaussianrecipe.py | 4 ---- docs/examples/npintensity.py | 6 ++---- docs/examples/npintensityII.py | 5 ++--- docs/examples/nppdfcrystal.py | 2 -- docs/examples/nppdfobjcryst.py | 3 --- docs/examples/nppdfsas.py | 3 --- docs/examples/simplepdf.py | 1 - docs/examples/simplepdftwophase.py | 1 - docs/examples/simplerecipe.py | 1 - docs/examples/threedoublepeaks.py | 2 -- src/diffpy/srfit/equation/builder.py | 1 - src/diffpy/srfit/equation/equationmod.py | 1 - src/diffpy/srfit/equation/literals/operators.py | 12 ++++++------ src/diffpy/srfit/equation/visitors/swapper.py | 3 --- src/diffpy/srfit/equation/visitors/validator.py | 1 - src/diffpy/srfit/exceptions.py | 1 - src/diffpy/srfit/fitbase/constraint.py | 1 - src/diffpy/srfit/fitbase/fitcontribution.py | 1 - src/diffpy/srfit/fitbase/fitrecipe.py | 4 ---- src/diffpy/srfit/fitbase/fitresults.py | 8 ++++---- src/diffpy/srfit/fitbase/recipeorganizer.py | 5 ----- src/diffpy/srfit/interface/interface.py | 12 ++++-------- src/diffpy/srfit/pdf/basepdfgenerator.py | 1 - src/diffpy/srfit/pdf/characteristicfunctions.py | 1 - src/diffpy/srfit/pdf/pdfparser.py | 1 - src/diffpy/srfit/sas/sasimport.py | 1 - src/diffpy/srfit/structure/objcrystparset.py | 4 ---- src/diffpy/srfit/structure/sgconstraints.py | 8 -------- src/diffpy/srfit/structure/srrealparset.py | 1 - src/diffpy/srfit/util/argbinders.py | 1 - tests/test_builder.py | 1 - tests/test_characteristicfunctions.py | 1 - tests/test_constraint.py | 2 -- tests/test_equation.py | 2 -- tests/test_fitrecipe.py | 1 - tests/test_literals.py | 2 -- tests/test_objcrystparset.py | 2 -- tests/test_profile.py | 1 - tests/test_recipeorganizer.py | 7 ------- tests/test_restraint.py | 1 - tests/test_speed.py | 5 ----- tests/test_visitors.py | 3 --- 52 files changed, 18 insertions(+), 126 deletions(-) diff --git a/docs/examples/coreshellnp.py b/docs/examples/coreshellnp.py index 8560221d..f2f2637c 100644 --- a/docs/examples/coreshellnp.py +++ b/docs/examples/coreshellnp.py @@ -38,7 +38,6 @@ def makeRecipe(stru1, stru2, datname): """Create a fitting recipe for crystalline PDF data.""" - # The Profile profile = Profile() @@ -138,7 +137,6 @@ def makeRecipe(stru1, stru2, datname): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # All this should be pretty familiar by now. r = recipe.cdszns.profile.x g = recipe.cdszns.profile.y @@ -162,7 +160,6 @@ def plotResults(recipe): def main(): """Set up and refine the recipe.""" - # Make the data and the recipe cdsciffile = "data/CdS.cif" znsciffile = "data/ZnS.cif" diff --git a/docs/examples/crystalpdf.py b/docs/examples/crystalpdf.py index cdd3472e..b378ff7d 100644 --- a/docs/examples/crystalpdf.py +++ b/docs/examples/crystalpdf.py @@ -43,7 +43,6 @@ def makeRecipe(ciffile, datname): """Create a fitting recipe for crystalline PDF data.""" - # The Profile # This will be used to store the observed and calculated PDF profile. profile = Profile() @@ -133,7 +132,6 @@ def makeRecipe(ciffile, datname): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # All this should be pretty familiar by now. r = recipe.nickel.profile.x g = recipe.nickel.profile.y diff --git a/docs/examples/crystalpdfall.py b/docs/examples/crystalpdfall.py index 37a57c78..71d8da0f 100644 --- a/docs/examples/crystalpdfall.py +++ b/docs/examples/crystalpdfall.py @@ -57,7 +57,6 @@ def makeRecipe( ciffile_ni, ciffile_si, xdata_ni, ndata_ni, xdata_si, xdata_sini ): """Create a fitting recipe for crystalline PDF data.""" - # The Profiles # We need a profile for each data set. xprofile_ni = makeProfile(xdata_ni) @@ -147,7 +146,6 @@ def makeRecipe( def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # All this should be pretty familiar by now. xnickel = recipe.xnickel xr_ni = xnickel.profile.x diff --git a/docs/examples/crystalpdfobjcryst.py b/docs/examples/crystalpdfobjcryst.py index 43a98e4d..3f4787f5 100644 --- a/docs/examples/crystalpdfobjcryst.py +++ b/docs/examples/crystalpdfobjcryst.py @@ -38,7 +38,6 @@ def makeRecipe(ciffile, datname): """Create a fitting recipe for crystalline PDF data.""" - # The Profile # This will be used to store the observed and calculated PDF profile. profile = Profile() diff --git a/docs/examples/crystalpdftwodata.py b/docs/examples/crystalpdftwodata.py index 03458fa8..57dc9d12 100644 --- a/docs/examples/crystalpdftwodata.py +++ b/docs/examples/crystalpdftwodata.py @@ -39,7 +39,6 @@ def makeRecipe(ciffile, xdatname, ndatname): """Create a fitting recipe for crystalline PDF data.""" - # The Profiles # We need a profile for each data set. This means that we will need two # FitContributions as well. @@ -138,7 +137,6 @@ def makeRecipe(ciffile, xdatname, ndatname): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # All this should be pretty familiar by now. xr = recipe.xnickel.profile.x xg = recipe.xnickel.profile.y diff --git a/docs/examples/crystalpdftwophase.py b/docs/examples/crystalpdftwophase.py index c2dbcf78..b62945c7 100644 --- a/docs/examples/crystalpdftwophase.py +++ b/docs/examples/crystalpdftwophase.py @@ -39,7 +39,6 @@ def makeRecipe(niciffile, siciffile, datname): """Create a fitting recipe for crystalline PDF data.""" - # The Profile profile = Profile() @@ -155,7 +154,6 @@ def makeRecipe(niciffile, siciffile, datname): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # All this should be pretty familiar by now. r = recipe.nisi.profile.x g = recipe.nisi.profile.y diff --git a/docs/examples/debyemodel.py b/docs/examples/debyemodel.py index 7813be4e..549b9b09 100644 --- a/docs/examples/debyemodel.py +++ b/docs/examples/debyemodel.py @@ -85,7 +85,6 @@ def makeRecipe(): optimize for the data/equation pair. This can be modified, but we won't do that here. """ - # The Profile # Create a Profile to hold the experimental and calculated signal. profile = Profile() @@ -160,7 +159,6 @@ def makeRecipe(): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # Plot this. # Note that since the contribution was given the name "pb", it is # accessible from the recipe with this name. This is a useful way to @@ -183,7 +181,6 @@ def plotResults(recipe): def main(): """The workflow of creating, running and inspecting a fit.""" - # Create the recipe recipe = makeRecipe() diff --git a/docs/examples/debyemodelII.py b/docs/examples/debyemodelII.py index a79df5f6..400daa6f 100644 --- a/docs/examples/debyemodelII.py +++ b/docs/examples/debyemodelII.py @@ -55,7 +55,6 @@ def makeRecipeII(): constrain the Debye temperature in each FitContribution to be the same. """ - # We'll throw these away. We just want the FitContributions that are # configured within the recipes. m1 = makeRecipe() @@ -96,7 +95,6 @@ def makeRecipeII(): def plotResults(recipe): """Display the results contained within a refined FitRecipe.""" - # The variable values are returned in the order in which the variables were # added to the FitRecipe. lowToffset, highToffset, thetaD = recipe.get_values() diff --git a/docs/examples/ellipsoidsas.py b/docs/examples/ellipsoidsas.py index 08586701..58bb0bb3 100644 --- a/docs/examples/ellipsoidsas.py +++ b/docs/examples/ellipsoidsas.py @@ -30,7 +30,6 @@ def makeRecipe(datname): """Create a fitting recipe for ellipsoidal SAS data.""" - # The Profile # This will be used to store the observed and calculated I(Q) data. profile = Profile() @@ -89,7 +88,6 @@ def makeRecipe(datname): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # All this should be pretty familiar by now. r = recipe.ellipsoid.profile.x y = recipe.ellipsoid.profile.y diff --git a/docs/examples/gaussiangenerator.py b/docs/examples/gaussiangenerator.py index 69c1507c..fc41c6fb 100644 --- a/docs/examples/gaussiangenerator.py +++ b/docs/examples/gaussiangenerator.py @@ -125,7 +125,6 @@ def makeRecipe(): This will create a FitContribution that uses the GaussianGenerator, associate this with a Profile, and use this to define a FitRecipe. """ - # The Profile # Create a Profile to hold the experimental and calculated signal. profile = Profile() diff --git a/docs/examples/gaussianrecipe.py b/docs/examples/gaussianrecipe.py index d0745660..93e3ff60 100644 --- a/docs/examples/gaussianrecipe.py +++ b/docs/examples/gaussianrecipe.py @@ -58,7 +58,6 @@ def main(): """The workflow of creating, running and inspecting a fit.""" - # Start by creating the recipe. The recipe describes the data to be fit, # the profile generator used to simulate the data and the variables that # will be tuned by the optimizer. @@ -95,7 +94,6 @@ def makeRecipe(): Once we define the FitRecipe, we can send it an optimizer to be optimized. See the 'scipyOptimize' function. """ - # The Profile # Create a Profile to hold the experimental and calculated signal. profile = Profile() @@ -168,7 +166,6 @@ def scipyOptimize(recipe): we can be minimized using a scipy optimizer. The details are described in the source. """ - # We're going to use the least-squares (Levenberg-Marquardt) optimizer from # scipy. We simply have to give it the function to minimize # (recipe.residual) and the starting values of the Variables @@ -183,7 +180,6 @@ def scipyOptimize(recipe): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # We can access the data and fit profile through the Profile we created # above. We get to it through our FitContribution, which we named "g1". # diff --git a/docs/examples/npintensity.py b/docs/examples/npintensity.py index eaf17012..bd9661ea 100644 --- a/docs/examples/npintensity.py +++ b/docs/examples/npintensity.py @@ -181,7 +181,6 @@ def makeRecipe(strufile, datname): This will create a FitContribution that uses the IntensityGenerator, associate this with a Profile, and use this to define a FitRecipe. """ - # The Profile # Create a Profile. This will hold the experimental and calculated signal. profile = Profile() @@ -226,7 +225,8 @@ def makeRecipe(strufile, datname): # We will define the background as a string. - bkgdstr = "b0 + b1*q + b2*q**2 + b3*q**3 + b4*q**4 + b5*q**5 + b6*q**6 +\ + bkgdstr =\ + "b0 + b1*q + b2*q**2 + b3*q**3 + b4*q**4 + b5*q**5 + b6*q**6 +\ b7*q**7 + b8*q**8 + b9*q**9" # This creates a callable equation named "bkgd" within the FitContribution, @@ -336,7 +336,6 @@ def main(): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # All this should be pretty familiar by now. q = recipe.bucky.profile.x @@ -484,7 +483,6 @@ def makeData(strufile, q, datname, scale, a, Uiso, sig, bkgc, nl=1): bkgc -- A parameter that gives minor control of the background. nl -- Noise level (0, inf), default 1, larger -> less noise. """ - from diffpy.structure import Structure S = Structure() diff --git a/docs/examples/npintensityII.py b/docs/examples/npintensityII.py index 5a6415a6..e8cbad0c 100644 --- a/docs/examples/npintensityII.py +++ b/docs/examples/npintensityII.py @@ -63,7 +63,6 @@ def makeRecipe(strufile, datname1, datname2): (which is generated by the IntensityGenerator when we load the structure) in both generators. """ - # The Profiles # Create two Profiles for the two FitContributions. profile1 = Profile() @@ -102,7 +101,8 @@ def makeRecipe(strufile, datname1, datname2): # same names. FitContributions are isolated namespaces than only share # information if you tell them to by using addParameter or # add_parameter_set. - bkgdstr = "b0 + b1*q + b2*q**2 + b3*q**3 + b4*q**4 + b5*q**5 + b6*q**6 +\ + bkgdstr =\ + "b0 + b1*q + b2*q**2 + b3*q**3 + b4*q**4 + b5*q**5 + b6*q**6 +\ b7*q**7 +b8*q**8 + b9*q**9" contribution1.register_string_function(bkgdstr, "bkgd") @@ -189,7 +189,6 @@ def gaussian(q, q0, width): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # plotting song and dance q = recipe.bucky1.profile.x diff --git a/docs/examples/nppdfcrystal.py b/docs/examples/nppdfcrystal.py index a568e8b9..39f12354 100644 --- a/docs/examples/nppdfcrystal.py +++ b/docs/examples/nppdfcrystal.py @@ -39,7 +39,6 @@ def makeRecipe(ciffile, grdata): """Make a recipe to model a crystal-like nanoparticle PDF.""" - # Set up a PDF fit as has been done in other examples. pdfprofile = Profile() @@ -84,7 +83,6 @@ def makeRecipe(ciffile, grdata): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # All this should be pretty familiar by now. r = recipe.pdf.profile.x g = recipe.pdf.profile.y diff --git a/docs/examples/nppdfobjcryst.py b/docs/examples/nppdfobjcryst.py index 03511d19..6c702172 100644 --- a/docs/examples/nppdfobjcryst.py +++ b/docs/examples/nppdfobjcryst.py @@ -34,7 +34,6 @@ def makeRecipe(molecule, datname): """Create a recipe that uses the DebyePDFGenerator.""" - # The Profile profile = Profile() @@ -110,7 +109,6 @@ def makeRecipe(molecule, datname): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # Plot this. r = recipe.bucky.profile.x g = recipe.bucky.profile.y @@ -221,7 +219,6 @@ def main(): def makeC60(): """Make the C60 molecule using pyobjcryst.""" - from pyobjcryst.crystal import Crystal from pyobjcryst.molecule import Molecule from pyobjcryst.scatteringpower import ScatteringPowerAtom diff --git a/docs/examples/nppdfsas.py b/docs/examples/nppdfsas.py index 2aac74b4..a4a54a6f 100644 --- a/docs/examples/nppdfsas.py +++ b/docs/examples/nppdfsas.py @@ -45,7 +45,6 @@ def makeRecipe(ciffile, grdata, iqdata): The fit I(q) is fed into the calculation of G(r), which provides feedback for the fit parameters of both. """ - # Create a PDF contribution as before pdfprofile = Profile() pdfparser = ProfileParser() @@ -122,7 +121,6 @@ def makeRecipe(ciffile, grdata, iqdata): def fitRecipe(recipe): """We refine in stages to help the refinement converge.""" - # Tune SAS. recipe.set_weight(recipe.pdf, 0) recipe.fix("all") @@ -149,7 +147,6 @@ def fitRecipe(recipe): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # All this should be pretty familiar by now. r = recipe.pdf.profile.x g = recipe.pdf.profile.y diff --git a/docs/examples/simplepdf.py b/docs/examples/simplepdf.py index a81bd83d..0611dc08 100644 --- a/docs/examples/simplepdf.py +++ b/docs/examples/simplepdf.py @@ -31,7 +31,6 @@ def makeRecipe(ciffile, datname): """Create a fitting recipe for crystalline PDF data.""" - # Work directly with a custom PDFContribution to load the data contribution = PDFContribution("nickel") contribution.loadData(datname) diff --git a/docs/examples/simplepdftwophase.py b/docs/examples/simplepdftwophase.py index 0b7ee046..9d7202b9 100644 --- a/docs/examples/simplepdftwophase.py +++ b/docs/examples/simplepdftwophase.py @@ -27,7 +27,6 @@ def makeRecipe(niciffile, siciffile, datname): """Create a fitting recipe for crystalline PDF data.""" - # Load data and add it to the profile contribution = PDFContribution("nisi") contribution.loadData(datname) diff --git a/docs/examples/simplerecipe.py b/docs/examples/simplerecipe.py index cb7d7b69..d0244d92 100644 --- a/docs/examples/simplerecipe.py +++ b/docs/examples/simplerecipe.py @@ -27,7 +27,6 @@ def main(): """Set up a simple recipe in a few lines.""" - # The SimpleRecipe class is a type of FitRecipe. It provides attribute-like # access to variables and a residual function that can be minimized. recipe = SimpleRecipe() diff --git a/docs/examples/threedoublepeaks.py b/docs/examples/threedoublepeaks.py index ecf01bf4..7802b222 100644 --- a/docs/examples/threedoublepeaks.py +++ b/docs/examples/threedoublepeaks.py @@ -176,7 +176,6 @@ def scipyOptimize(recipe): we can be minimized using a scipy optimizer. The details are described in the source. """ - # We're going to use the least-squares (Levenberg-Marquardt) optimizer from # scipy. We simply have to give it the function to minimize # (recipe.residual) and the starting values of the Variables @@ -191,7 +190,6 @@ def scipyOptimize(recipe): def plotResults(recipe): """Plot the results contained within a refined FitRecipe.""" - # We can access the data and fit profile through the Profile we created # above. We get to it through our FitContribution, which we named "g1". # diff --git a/src/diffpy/srfit/equation/builder.py b/src/diffpy/srfit/equation/builder.py index a41f6bda..1bc187ec 100644 --- a/src/diffpy/srfit/equation/builder.py +++ b/src/diffpy/srfit/equation/builder.py @@ -359,7 +359,6 @@ def _prepare_builders(self, eqstr, buildargs, argclass, argkw): Returns a dictionary of the name, BaseBuilder pairs. """ - eqargs = self._get_undefined_args(eqstr) # Raise an error if there are arguments that need to be created, but diff --git a/src/diffpy/srfit/equation/equationmod.py b/src/diffpy/srfit/equation/equationmod.py index 5be7ba0c..3c05dcbc 100644 --- a/src/diffpy/srfit/equation/equationmod.py +++ b/src/diffpy/srfit/equation/equationmod.py @@ -156,7 +156,6 @@ def setRoot(self, root): Raises: ValueError if errors are found in the Literal tree. """ - # Validate the new root validate(root) diff --git a/src/diffpy/srfit/equation/literals/operators.py b/src/diffpy/srfit/equation/literals/operators.py index bb830b05..6715f309 100644 --- a/src/diffpy/srfit/equation/literals/operators.py +++ b/src/diffpy/srfit/equation/literals/operators.py @@ -144,9 +144,9 @@ class UnaryOperator(Operator): """Abstract class for an unary operator with one input and one result. - This base class defines the `nin` and `nout` attributes. The derived - concrete operator must provide the remaining abstract attributes - of the `Operator` class. + This base class defines the `nin` and `nout` attributes. The + derived concrete operator must provide the remaining abstract + attributes of the `Operator` class. """ nin = 1 @@ -158,9 +158,9 @@ class BinaryOperator(Operator): """Abstract class for a binary operator with two inputs and one result. - This base class defines the `nin` and `nout` attributes. The derived - concrete operator must define the remaining abstract attributes - of the `Operator` class. + This base class defines the `nin` and `nout` attributes. The + derived concrete operator must define the remaining abstract + attributes of the `Operator` class. """ nin = 2 diff --git a/src/diffpy/srfit/equation/visitors/swapper.py b/src/diffpy/srfit/equation/visitors/swapper.py index ddd49ef6..5c76323b 100644 --- a/src/diffpy/srfit/equation/visitors/swapper.py +++ b/src/diffpy/srfit/equation/visitors/swapper.py @@ -46,7 +46,6 @@ def __init__(self, oldlit, newlit): The literal to be placed into the literal tree. See the class for how the replacement takes place. """ - self.newlit = newlit self.oldlit = oldlit @@ -60,7 +59,6 @@ def onArgument(self, arg): Tell the parent to swap the old Argument with the replacement Literal. """ - if arg is self.oldlit: self._swap = True @@ -72,7 +70,6 @@ def onOperator(self, op): Tell the parent to swap the old Operator with the replacement Literal. """ - # Check to see if we need to swap out this Operator. If so, then we # don't need to traverse into its arguments. if op is self.oldlit: diff --git a/src/diffpy/srfit/equation/visitors/validator.py b/src/diffpy/srfit/equation/visitors/validator.py index 13f5e4e5..32d9682b 100644 --- a/src/diffpy/srfit/equation/visitors/validator.py +++ b/src/diffpy/srfit/equation/visitors/validator.py @@ -72,7 +72,6 @@ def onOperator(self, op): The Operator must be an instance of OperatorABC from diffpy.srfit.equation.literals.abcs """ - if not isinstance(op, OperatorABC): m = msg % (op, OperatorABC.__name__) self.errors.append(m) diff --git a/src/diffpy/srfit/exceptions.py b/src/diffpy/srfit/exceptions.py index f61ada87..227d6cf1 100644 --- a/src/diffpy/srfit/exceptions.py +++ b/src/diffpy/srfit/exceptions.py @@ -16,7 +16,6 @@ Exceptions used for SrFit - specific errors. """ - class SrFitError(Exception): """Generic error in SrFit expressions or recipe.""" diff --git a/src/diffpy/srfit/fitbase/constraint.py b/src/diffpy/srfit/fitbase/constraint.py index dab6002b..8119c820 100644 --- a/src/diffpy/srfit/fitbase/constraint.py +++ b/src/diffpy/srfit/fitbase/constraint.py @@ -83,7 +83,6 @@ def add_constraint(self, par, eq): ValueError If par is constant or already constrained. """ - if par.const: raise ValueError("The parameter '%s' is constant" % par) diff --git a/src/diffpy/srfit/fitbase/fitcontribution.py b/src/diffpy/srfit/fitbase/fitcontribution.py index 710f492c..e1c29f7f 100644 --- a/src/diffpy/srfit/fitbase/fitcontribution.py +++ b/src/diffpy/srfit/fitbase/fitcontribution.py @@ -428,7 +428,6 @@ def getResidualEquation(self): diffpy.srfit.fitbase.FitContribution.get_residual_equation instead. """ - return self.get_residual_equation() def residual(self): diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index d4fdf279..21dbd8d1 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -582,7 +582,6 @@ def _prepare(self): AttributeError If there are variables without a value. """ - # Only prepare if the configuration has changed within the recipe # hierarchy. if self._ready: @@ -633,7 +632,6 @@ def __verify_profiles(self): def __verify_parameters(self): """Verify that all Parameters have values.""" - # Get all parameters with a value of None badpars = [] for par in self.iterate_over_parameters(): @@ -812,7 +810,6 @@ def delete_variable(self, var): ValueError If var is not part of the FitRecipe. """ - self._remove_parameter(var) self._tagmanager.untag(var) return @@ -1534,7 +1531,6 @@ def set_plot_defaults(self, **kwargs): fit_color='red' ) """ - for key in kwargs: if key not in self.plot_options: print( diff --git a/src/diffpy/srfit/fitbase/fitresults.py b/src/diffpy/srfit/fitbase/fitresults.py index 18f0423c..afab48fa 100644 --- a/src/diffpy/srfit/fitbase/fitresults.py +++ b/src/diffpy/srfit/fitbase/fitresults.py @@ -259,10 +259,11 @@ def update(self): return def _calculate_covariance(self): - """Calculate the covariance matrix. This is called by update. + """Calculate the covariance matrix. - This code borrowed from PARK. It finds the pseudo-inverse of the - Jacobian using the singular value decomposition. + This is called by update. This code borrowed from PARK. + It finds the pseudo-inverse of the Jacobian using the + singular value decomposition. """ try: J = self._calculate_jacobian() @@ -873,7 +874,6 @@ def initializeRecipe(recipe, results): An open file-like object, name of a file that contains results from FitResults or a string containing fit results. """ - mpairs = resultsDictionary(results) if not mpairs: raise AttributeError("Cannot find results") diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index c84f04a2..e329dfb2 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -479,7 +479,6 @@ def _add_object(self, obj, d, check=True): Raises ValueError if the object has the same name as some other managed object. """ - # Check name if not obj.name: message = "%s has no name" % obj.__class__.__name__ @@ -674,7 +673,6 @@ def _add_parameter(self, parameter, check=True): Raises ValueError if the Parameter has the same name as a contained RecipeContainer. """ - # Store the Parameter RecipeContainer._add_object(self, parameter, self._parameters, check) @@ -789,7 +787,6 @@ def register_function(self, function, name=None, argnames=None): equation_object : Equation The callable Equation object. """ - # If the function is an equation, we treat it specially. This is # required so that the objects observed by the root get observed if the # Equation is used within another equation. It is assumed that a plain @@ -907,7 +904,6 @@ def register_string_function(self, function_str, name, func_params={}): equation_object : Equation The callable Equation object. """ - # Build the equation instance. eq = get_equation_from_string( function_str, self._eqfactory, ns=func_params, buildargs=True @@ -1629,7 +1625,6 @@ def get_equation_from_string( If buildargs is False and there are undefined parameters in eqstr or if ns uses a name that is already defined in the factory. """ - defined = set(factory.builders.keys()) # Check if ns overloads any parameters. diff --git a/src/diffpy/srfit/interface/interface.py b/src/diffpy/srfit/interface/interface.py index 308e0471..31fef6dd 100644 --- a/src/diffpy/srfit/interface/interface.py +++ b/src/diffpy/srfit/interface/interface.py @@ -147,10 +147,8 @@ def f(*args): def _applymanyargs(args, f): """Apply arguments to a function. - Args can be any of the following. - arg - (arg1, arg2, ...) - ((arg1a, arg1b, ...), ...) + Args can be any of the following. arg (arg1, arg2, ...) ((arg1a, + arg1b, ...), ...) """ if not hasattr(args, "__iter__"): f(args) @@ -168,10 +166,8 @@ def _applymanyargs(args, f): def _applyargs(args, f): """Apply arguments to a function. - Args can be any of the following. - arg - (arg1, arg2, ...) - ((arg1a, arg1b, ...), ...) + Args can be any of the following. arg (arg1, arg2, ...) ((arg1a, + arg1b, ...), ...) """ if not hasattr(args, "__iter__"): f(args) diff --git a/src/diffpy/srfit/pdf/basepdfgenerator.py b/src/diffpy/srfit/pdf/basepdfgenerator.py index e8566b84..837dce98 100644 --- a/src/diffpy/srfit/pdf/basepdfgenerator.py +++ b/src/diffpy/srfit/pdf/basepdfgenerator.py @@ -244,7 +244,6 @@ def setStructure(self, stru, name="phase", periodic=True): periodicity, in which case this will have no effect on the PDF calculation. """ - # Create the ParameterSet parset = struToParameterSet(name, stru) diff --git a/src/diffpy/srfit/pdf/characteristicfunctions.py b/src/diffpy/srfit/pdf/characteristicfunctions.py index 19f8364a..d1e239d1 100644 --- a/src/diffpy/srfit/pdf/characteristicfunctions.py +++ b/src/diffpy/srfit/pdf/characteristicfunctions.py @@ -408,7 +408,6 @@ def __init__(self, name, model): def __call__(self, r): """Calculate the characteristic function from the transform of the BaseModel.""" - # Determine q-values. # We want very fine r-spacing so we can properly normalize f(r). This # equates to having a large qmax so that the Fourier transform is diff --git a/src/diffpy/srfit/pdf/pdfparser.py b/src/diffpy/srfit/pdf/pdfparser.py index bfb10a15..acfff0dc 100644 --- a/src/diffpy/srfit/pdf/pdfparser.py +++ b/src/diffpy/srfit/pdf/pdfparser.py @@ -139,7 +139,6 @@ def parseString(self, patstring): Raises ParseError if the string cannot be parsed """ - # useful regex patterns: rx = {"f": r"[-+]?(\d+(\.\d*)?|\d*\.\d+)([eE][-+]?\d+)?"} # find where does the data start diff --git a/src/diffpy/srfit/sas/sasimport.py b/src/diffpy/srfit/sas/sasimport.py index cfd10fa8..b604d3d7 100644 --- a/src/diffpy/srfit/sas/sasimport.py +++ b/src/diffpy/srfit/sas/sasimport.py @@ -14,7 +14,6 @@ ############################################################################## """Universal import functions for volatile SasView/SansViews API-s.""" - def sasimport(modname): """Import specified module from the SasView sas package. diff --git a/src/diffpy/srfit/structure/objcrystparset.py b/src/diffpy/srfit/structure/objcrystparset.py index 25cd50d8..3764b477 100644 --- a/src/diffpy/srfit/structure/objcrystparset.py +++ b/src/diffpy/srfit/structure/objcrystparset.py @@ -1335,7 +1335,6 @@ def __init__(self, name, atom1, atom2, value=None, const=False, mode=None): If this is None (default), then a new StretchModeBondLength will be built. """ - # Create the mode self.mode = mode if mode is None: @@ -1495,7 +1494,6 @@ def __init__( A pre-built mode to place in this Parameter. If this is None (default), then a StretchMode will be built. """ - # Create the stretch mode self.mode = mode if mode is None: @@ -1676,7 +1674,6 @@ def __init__( A pre-built mode to place in this Parameter. If this is None (default), then a StretchMode will be built. """ - # Create the stretch mode self.mode = mode if mode is None: @@ -1802,7 +1799,6 @@ class ObjCrystCrystalParSet(SrRealParSet): occ Occupancy of the scatterer on its crystal site (ParameterWraper) """ - def __init__(self, name, cryst): """Initialize. diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 893c90a0..aed93a3b 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -101,7 +101,6 @@ def constrainAsSpaceGroup( b and c are constrained to a, and alpha, beta and gamma are fixed to 90. """ - from diffpy.structure.spacegroups import GetSpaceGroup, SpaceGroup sg = spacegroup @@ -138,7 +137,6 @@ def _constrain_as_space_group( sg diffpy.structure.spacegroups.SpaceGroup instance """ - from diffpy.structure.symmetryutilities import stdUsymbols if scatterers is None: @@ -356,7 +354,6 @@ def _make_constraints(self): This works as described by the constrainAsSpaceGroup method. """ - # Start by clearing the constraints self._clear_constraints() @@ -431,7 +428,6 @@ def _clear_constraints(self): def _constrain_lattice(self): """Constrain the lattice parameters.""" - if not self.constrainlat: return @@ -474,7 +470,6 @@ def _constrain_xyzs(self, positions): positions The coordinates of the scatterers. """ - from diffpy.structure.symmetryutilities import SymmetryConstraints sg = self.sg @@ -517,7 +512,6 @@ def _constrain_adps(self, positions): positions The coordinates of the scatterers. """ - from diffpy.structure.symmetryutilities import ( SymmetryConstraints, stdUsymbols, @@ -639,8 +633,6 @@ def __add_par(self, parname, par): def _constrain_triclinic(lattice): """Make constraints for Triclinic systems.""" return - - def _constrain_monoclinic(lattice): """Make constraints for Monoclinic systems. diff --git a/src/diffpy/srfit/structure/srrealparset.py b/src/diffpy/srfit/structure/srrealparset.py index 4ed31ffc..e98f06c7 100644 --- a/src/diffpy/srfit/structure/srrealparset.py +++ b/src/diffpy/srfit/structure/srrealparset.py @@ -63,7 +63,6 @@ def restrainBVS(self, sig=1, scaled=False): Returns the BVSRestraint object for use with the 'unrestrain' method. """ - # Create the Restraint object res = BVSRestraint(self, sig, scaled) # Add it to the _restraints set diff --git a/src/diffpy/srfit/util/argbinders.py b/src/diffpy/srfit/util/argbinders.py index 71db89b4..be22dd46 100644 --- a/src/diffpy/srfit/util/argbinders.py +++ b/src/diffpy/srfit/util/argbinders.py @@ -14,7 +14,6 @@ ############################################################################## """Functions for binding arguments of callable objects.""" - class bind2nd(object): """Freeze second argument of a callable object to a given constant.""" diff --git a/tests/test_builder.py b/tests/test_builder.py index cf1c3681..d4b38fd7 100644 --- a/tests/test_builder.py +++ b/tests/test_builder.py @@ -50,7 +50,6 @@ def testRegisterArg(make_args, noObserversInGlobalBuilders): def testRegisterOperator(make_args, noObserversInGlobalBuilders): """Try to use an operator without arguments in an equation.""" - factory = builder.EquationFactory() v1, v2, v3, v4 = make_args(4) diff --git a/tests/test_characteristicfunctions.py b/tests/test_characteristicfunctions.py index b64e254c..6a0a79a8 100644 --- a/tests/test_characteristicfunctions.py +++ b/tests/test_characteristicfunctions.py @@ -131,7 +131,6 @@ def testCylinder(sas_available): + "latest sasview API" ) from sasmodels.sasview_model import find_model, load_standard_models - load_standard_models() """Make sure cylinder works over different r-ranges.""" radius = 100 diff --git a/tests/test_constraint.py b/tests/test_constraint.py index f173de14..f82c4384 100644 --- a/tests/test_constraint.py +++ b/tests/test_constraint.py @@ -26,7 +26,6 @@ class TestConstraint(unittest.TestCase): def test_constrain_parameter(self): """Test the Constraint class.""" - p1 = Parameter("p1", 1) p2 = Parameter("p2", 2) @@ -65,7 +64,6 @@ class TestConstraint_deprecated(unittest.TestCase): def testConstraint(self): """Test the Constraint class.""" - p1 = Parameter("p1", 1) p2 = Parameter("p2", 2) diff --git a/tests/test_equation.py b/tests/test_equation.py index c4bc7cd8..bd89881e 100644 --- a/tests/test_equation.py +++ b/tests/test_equation.py @@ -22,7 +22,6 @@ def testSimpleFunction(make_args, noObserversInGlobalBuilders): """Test a simple function.""" - # Make some variables v1, v2, v3, v4, c = make_args(5) c.name = "c" @@ -111,7 +110,6 @@ def testSimpleFunction(make_args, noObserversInGlobalBuilders): def testEmbeddedEquation(make_args, noObserversInGlobalBuilders): """Test a simple function.""" - # Make some variables v1, v2, v3, v4, c = make_args(5) c.name = "c" diff --git a/tests/test_fitrecipe.py b/tests/test_fitrecipe.py index b697f531..5eceb921 100644 --- a/tests/test_fitrecipe.py +++ b/tests/test_fitrecipe.py @@ -200,7 +200,6 @@ def testVars(self): def testResidual(self): """Test the residual and everything that can change it.""" - # With thing set up as they are, the residual should be 0 res = self.recipe.residual() self.assertAlmostEqual(0, dot(res, res)) diff --git a/tests/test_literals.py b/tests/test_literals.py index 970a2702..891bbde9 100644 --- a/tests/test_literals.py +++ b/tests/test_literals.py @@ -43,7 +43,6 @@ def testIdentity(self): def testValue(self): """Test value setting.""" - a = literals.Argument() self.assertEqual(None, a.getValue()) @@ -160,7 +159,6 @@ class TestConvolutionOperator(unittest.TestCase): def testValue(self): """Make sure the convolution operator is working properly.""" - exp = numpy.exp x = numpy.linspace(0, 10, 1000) diff --git a/tests/test_objcrystparset.py b/tests/test_objcrystparset.py index f905a9eb..533092c2 100644 --- a/tests/test_objcrystparset.py +++ b/tests/test_objcrystparset.py @@ -164,7 +164,6 @@ def testImplicitBondAngleRestraints(self): def testObjCrystParSet(self): """Test the structure conversion.""" - occryst = self.occryst ocmol = self.ocmol cryst = ObjCrystCrystalParSet("bucky", occryst) @@ -652,7 +651,6 @@ def sgsEquivalent(self, sg1, sg2): def xtestCreateSpaceGroup(self): """Check all sgtbx space groups for proper conversion to SpaceGroup.""" - try: from cctbx import sgtbx except ImportError: diff --git a/tests/test_profile.py b/tests/test_profile.py index b69f6f7b..ccbef6b2 100644 --- a/tests/test_profile.py +++ b/tests/test_profile.py @@ -277,7 +277,6 @@ def test_savetxt(self): def testLoadtxt(datafile): """Test the loadtxt method.""" - prof = Profile() data = datafile("testdata.txt") diff --git a/tests/test_recipeorganizer.py b/tests/test_recipeorganizer.py index 08d46dec..99d8ee0d 100644 --- a/tests/test_recipeorganizer.py +++ b/tests/test_recipeorganizer.py @@ -35,7 +35,6 @@ class TestEquationFromString(unittest.TestCase): def test_get_equation_from_string(self): """Test the get_equation_from_string method.""" - p1 = Parameter("p1", 1) p2 = Parameter("p2", 2) p3 = Parameter("p3", 3) @@ -189,7 +188,6 @@ def tearDown(self): def testNewParameter(self): """Test the addParameter method.""" - m = self.m p1 = Parameter("p1", 1) @@ -205,7 +203,6 @@ def testNewParameter(self): def testAddParameter(self): """Test the addParameter method.""" - m = self.m p1 = Parameter("p1", 1) @@ -243,7 +240,6 @@ def testAddParameter(self): def testRemoveParameter(self): """Test removeParameter method.""" - m = self.m p1 = Parameter("p1", 1) @@ -268,7 +264,6 @@ def testRemoveParameter(self): def test_constrain_parameter(self): """Test the constrain method.""" - p1 = self.m._new_parameter("p1", 1) p2 = self.m._new_parameter("p2", 2) p3 = Parameter("p3", 3) @@ -337,7 +332,6 @@ def test_constrain_parameter(self): def test_add_restraint(self): """Test the restrain method.""" - p1 = Parameter("p1", 1) p2 = Parameter("p2", 2) p3 = Parameter("p3", 3) @@ -560,7 +554,6 @@ def __call__(self): def test_register_string_function(self): """Test registering string functions in various ways.""" - # Make an equation. eq1 = self.m.register_string_function("x**2 + 3", "eq1") eq1.x.set_value(0) diff --git a/tests/test_restraint.py b/tests/test_restraint.py index befae689..93a4daff 100644 --- a/tests/test_restraint.py +++ b/tests/test_restraint.py @@ -26,7 +26,6 @@ class TestRestraint(unittest.TestCase): def testRestraint(self): """Test the Restraint class.""" - p1 = Parameter("p1", 1) p2 = Parameter("p2", 2) diff --git a/tests/test_speed.py b/tests/test_speed.py index e859e4e0..a7d43b4a 100644 --- a/tests/test_speed.py +++ b/tests/test_speed.py @@ -35,7 +35,6 @@ def make_lazy_equation(make_args): """Make a lazy equation and see how fast it is.""" - # Make some variables v1, v2, v3, v4, v5, v6, v7 = make_args(7) @@ -83,7 +82,6 @@ def _f(a, b, c, d, e): def make_equation1(): """Make the same equation as the lazy one.""" - y = 50 * x def _f(a, b, c, d, e): @@ -205,7 +203,6 @@ def test_speed3(mutate=2): - diffpy.srfit.equation is slightly slower when using arrays, but not considerably worse than versus numpy alone. """ - from diffpy.srfit.equation.builder import EquationFactory factory = EquationFactory() @@ -294,7 +291,6 @@ def test_speed4(mutate=2): - diffpy.srfit.equation is slightly slower when using arrays, but not considerably worse than versus numpy alone. """ - from diffpy.srfit.equation.builder import EquationFactory factory = EquationFactory() @@ -353,7 +349,6 @@ def test_speed4(mutate=2): def test_weighted(mutate=2): """Show the benefits of a properly balanced equation tree.""" - from diffpy.srfit.equation.builder import EquationFactory factory = EquationFactory() diff --git a/tests/test_visitors.py b/tests/test_visitors.py index 9ae8698d..c7130be2 100644 --- a/tests/test_visitors.py +++ b/tests/test_visitors.py @@ -29,7 +29,6 @@ def setup(self, make_args): def testSimpleFunction(self): """Test a simple function.""" - # Make some variables v1, v2, v3, v4 = self.make_args(4) @@ -98,7 +97,6 @@ def setup(self, make_args): def testSimpleFunction(self): """Test a simple function.""" - # Make some variables v1, v2, v3, v4 = self.make_args(4) @@ -151,7 +149,6 @@ def setup(self, make_args): def testSimpleFunction(self): """Test a simple function.""" - # Make some variables v1, v2, v3, v4, v5 = self.make_args(5) From ccdcda0dd9cfea59783b0238e040c7a3bc1a0416 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 30 Jun 2026 17:20:49 -0400 Subject: [PATCH 5/8] fix docformatter and black conflicts --- docs/examples/npintensity.py | 3 +-- docs/examples/npintensityII.py | 3 +-- src/diffpy/srfit/exceptions.py | 3 +++ src/diffpy/srfit/sas/sasimport.py | 3 +++ src/diffpy/srfit/structure/objcrystparset.py | 1 + src/diffpy/srfit/structure/sgconstraints.py | 2 ++ src/diffpy/srfit/util/argbinders.py | 3 +++ tests/test_characteristicfunctions.py | 3 ++- 8 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/examples/npintensity.py b/docs/examples/npintensity.py index bd9661ea..586683bc 100644 --- a/docs/examples/npintensity.py +++ b/docs/examples/npintensity.py @@ -225,8 +225,7 @@ def makeRecipe(strufile, datname): # We will define the background as a string. - bkgdstr =\ - "b0 + b1*q + b2*q**2 + b3*q**3 + b4*q**4 + b5*q**5 + b6*q**6 +\ + bkgdstr = "b0 + b1*q + b2*q**2 + b3*q**3 + b4*q**4 + b5*q**5 + b6*q**6 +\ b7*q**7 + b8*q**8 + b9*q**9" # This creates a callable equation named "bkgd" within the FitContribution, diff --git a/docs/examples/npintensityII.py b/docs/examples/npintensityII.py index e8cbad0c..ff0d6bcd 100644 --- a/docs/examples/npintensityII.py +++ b/docs/examples/npintensityII.py @@ -101,8 +101,7 @@ def makeRecipe(strufile, datname1, datname2): # same names. FitContributions are isolated namespaces than only share # information if you tell them to by using addParameter or # add_parameter_set. - bkgdstr =\ - "b0 + b1*q + b2*q**2 + b3*q**3 + b4*q**4 + b5*q**5 + b6*q**6 +\ + bkgdstr = "b0 + b1*q + b2*q**2 + b3*q**3 + b4*q**4 + b5*q**5 + b6*q**6 +\ b7*q**7 +b8*q**8 + b9*q**9" contribution1.register_string_function(bkgdstr, "bkgd") diff --git a/src/diffpy/srfit/exceptions.py b/src/diffpy/srfit/exceptions.py index 227d6cf1..dee61bce 100644 --- a/src/diffpy/srfit/exceptions.py +++ b/src/diffpy/srfit/exceptions.py @@ -16,6 +16,9 @@ Exceptions used for SrFit - specific errors. """ +# FIXME: remove this line when black and docformatter agree. + + class SrFitError(Exception): """Generic error in SrFit expressions or recipe.""" diff --git a/src/diffpy/srfit/sas/sasimport.py b/src/diffpy/srfit/sas/sasimport.py index b604d3d7..523c9601 100644 --- a/src/diffpy/srfit/sas/sasimport.py +++ b/src/diffpy/srfit/sas/sasimport.py @@ -14,6 +14,9 @@ ############################################################################## """Universal import functions for volatile SasView/SansViews API-s.""" +# FIXME: remove this line when black and docformatter agree. + + def sasimport(modname): """Import specified module from the SasView sas package. diff --git a/src/diffpy/srfit/structure/objcrystparset.py b/src/diffpy/srfit/structure/objcrystparset.py index 3764b477..0739f8d9 100644 --- a/src/diffpy/srfit/structure/objcrystparset.py +++ b/src/diffpy/srfit/structure/objcrystparset.py @@ -1799,6 +1799,7 @@ class ObjCrystCrystalParSet(SrRealParSet): occ Occupancy of the scatterer on its crystal site (ParameterWraper) """ + def __init__(self, name, cryst): """Initialize. diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index aed93a3b..92cdde7b 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -633,6 +633,8 @@ def __add_par(self, parname, par): def _constrain_triclinic(lattice): """Make constraints for Triclinic systems.""" return + + def _constrain_monoclinic(lattice): """Make constraints for Monoclinic systems. diff --git a/src/diffpy/srfit/util/argbinders.py b/src/diffpy/srfit/util/argbinders.py index be22dd46..4c896308 100644 --- a/src/diffpy/srfit/util/argbinders.py +++ b/src/diffpy/srfit/util/argbinders.py @@ -14,6 +14,9 @@ ############################################################################## """Functions for binding arguments of callable objects.""" +# FIXME: remove this line when black and docformatter agree. + + class bind2nd(object): """Freeze second argument of a callable object to a given constant.""" diff --git a/tests/test_characteristicfunctions.py b/tests/test_characteristicfunctions.py index 6a0a79a8..c0b192ff 100644 --- a/tests/test_characteristicfunctions.py +++ b/tests/test_characteristicfunctions.py @@ -131,8 +131,9 @@ def testCylinder(sas_available): + "latest sasview API" ) from sasmodels.sasview_model import find_model, load_standard_models + load_standard_models() - """Make sure cylinder works over different r-ranges.""" + # Make sure cylinder works over different r-ranges. radius = 100 length = 30 From b06c67bf2fe433b68f183f628b2e6a7f9b1ae3f1 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 30 Jun 2026 17:22:22 -0400 Subject: [PATCH 6/8] chore: news v2 --- news/sync-w-main-v1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/sync-w-main-v1.rst b/news/sync-w-main-v1.rst index ca16abf2..4aa5933c 100644 --- a/news/sync-w-main-v1.rst +++ b/news/sync-w-main-v1.rst @@ -1,6 +1,6 @@ **Added:** -* No news needed: refactoring of pytest fixtures +* No news needed: refactoring of pytest fixtures and merging with main branch. **Changed:** From 63270c22fc67aa29f47ce95b8b4fb1771222c7ef Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 30 Jun 2026 17:25:39 -0400 Subject: [PATCH 7/8] clean up ugly docstring formating --- src/diffpy/srfit/fitbase/fitresults.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitresults.py b/src/diffpy/srfit/fitbase/fitresults.py index afab48fa..f3a48f23 100644 --- a/src/diffpy/srfit/fitbase/fitresults.py +++ b/src/diffpy/srfit/fitbase/fitresults.py @@ -261,9 +261,9 @@ def update(self): def _calculate_covariance(self): """Calculate the covariance matrix. - This is called by update. This code borrowed from PARK. - It finds the pseudo-inverse of the Jacobian using the - singular value decomposition. + This is called by update. This code borrowed from PARK. It finds + the pseudo-inverse of the Jacobian using the singular value + decomposition. """ try: J = self._calculate_jacobian() From d2c26d663cc2f1b3b69076441d3f04e41f043c88 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Tue, 30 Jun 2026 19:04:41 -0400 Subject: [PATCH 8/8] empty commit