From 7b067910456464c42a107f72b438843b114d7cd7 Mon Sep 17 00:00:00 2001 From: Sparks29032 Date: Fri, 29 May 2026 17:04:20 -0700 Subject: [PATCH 1/4] Change docformatter, update all other hooks --- .pre-commit-config.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e4a84d1..ec7ea40f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ ci: submodules: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v6.0.0 hooks: - id: check-yaml - id: end-of-file-fixer @@ -21,45 +21,45 @@ repos: - id: check-toml - id: check-added-large-files - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 26.3.1 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: 7.0.0 + rev: 7.3.0 hooks: - id: flake8 - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 9.0.0a3 hooks: - id: isort args: ["--profile", "black"] - repo: https://github.com/kynan/nbstripout - rev: 0.7.1 + rev: 0.9.1 hooks: - id: nbstripout - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v6.0.0 hooks: - id: no-commit-to-branch name: Prevent Commit to Main Branch args: ["--branch", "main"] stages: [pre-commit] - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.2 hooks: - id: codespell additional_dependencies: - tomli # prettier - multi formatter for .json, .yml, and .md files - repo: https://github.com/pre-commit/mirrors-prettier - rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8 + rev: v4.0.0-alpha.8 hooks: - id: prettier additional_dependencies: - "prettier@^3.2.4" # docformatter - PEP 257 compliant docstring formatter - - repo: https://github.com/s-weigand/docformatter - rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c + - repo: https://github.com/PyCQA/docformatter + rev: v1.7.8 hooks: - id: docformatter additional_dependencies: [tomli] From 8bff572f4203a50c3f297fb7fad4df624fc10df0 Mon Sep 17 00:00:00 2001 From: Sparks29032 Date: Fri, 29 May 2026 17:07:28 -0700 Subject: [PATCH 2/4] News --- news/docformatter.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/docformatter.rst diff --git a/news/docformatter.rst b/news/docformatter.rst new file mode 100644 index 00000000..2159732c --- /dev/null +++ b/news/docformatter.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Now use `PyCQA/docformatter` to format Python docstrings. + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 382f280a4b46997d449e054b6cff82ab136cb76a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 30 May 2026 00:08:22 +0000 Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit hooks --- .../morph/morph_helpers/transformpdftordf.py | 1 - .../morph/morph_helpers/transformrdftopdf.py | 1 - src/diffpy/morph/morph_io.py | 4 --- src/diffpy/morph/morphapp.py | 11 ++++--- src/diffpy/morph/morphpy.py | 2 +- src/diffpy/morph/morphs/__init__.py | 1 - src/diffpy/morph/morphs/morph.py | 7 +++-- src/diffpy/morph/morphs/morphchain.py | 4 +-- src/diffpy/morph/morphs/morphishape.py | 1 - src/diffpy/morph/morphs/morphresolution.py | 1 - src/diffpy/morph/morphs/morphrgrid.py | 1 - src/diffpy/morph/morphs/morphscale.py | 1 - src/diffpy/morph/morphs/morphshape.py | 1 - src/diffpy/morph/morphs/morphshift.py | 1 - src/diffpy/morph/morphs/morphsmear.py | 1 - src/diffpy/morph/morphs/morphstretch.py | 1 - src/diffpy/morph/plot.py | 2 -- src/diffpy/morph/refine.py | 4 +-- src/diffpy/morph/tools.py | 10 ++----- tests/debug.py | 1 - tests/test_morphapp.py | 30 +++++++++---------- tests/test_morphio.py | 14 ++++----- tests/test_morphpy.py | 2 +- tests/test_morphrgrid.py | 4 --- tests/test_morphshape.py | 1 - tests/test_morphshift.py | 4 +-- tests/test_morphsqueeze.py | 6 ++-- tests/test_morphstretch.py | 4 +-- tests/test_refine.py | 2 +- tests/test_tools.py | 1 - 30 files changed, 48 insertions(+), 76 deletions(-) diff --git a/src/diffpy/morph/morph_helpers/transformpdftordf.py b/src/diffpy/morph/morph_helpers/transformpdftordf.py index 31331ed7..c08c1860 100644 --- a/src/diffpy/morph/morph_helpers/transformpdftordf.py +++ b/src/diffpy/morph/morph_helpers/transformpdftordf.py @@ -14,7 +14,6 @@ ############################################################################## """Class TransformXtalPDFtoRDF -- Transform crystal PDFs to RDFs.""" - from diffpy.morph.morphs.morph import LABEL_GR, LABEL_RA, LABEL_RR, Morph diff --git a/src/diffpy/morph/morph_helpers/transformrdftopdf.py b/src/diffpy/morph/morph_helpers/transformrdftopdf.py index 54656ccf..acf732c0 100644 --- a/src/diffpy/morph/morph_helpers/transformrdftopdf.py +++ b/src/diffpy/morph/morph_helpers/transformrdftopdf.py @@ -14,7 +14,6 @@ ############################################################################## """Class TransformXtalRDFtoPDF -- Transform crystal RDFs to PDFs.""" - import numpy from diffpy.morph.morphs.morph import LABEL_GR, LABEL_RA, LABEL_RR, Morph diff --git a/src/diffpy/morph/morph_io.py b/src/diffpy/morph/morph_io.py index cf194f54..69f5dcf1 100644 --- a/src/diffpy/morph/morph_io.py +++ b/src/diffpy/morph/morph_io.py @@ -155,7 +155,6 @@ def single_morph_output( stdout_flag: bool Print to terminal when True (default False). """ - # Input and output parameters morphs_in = "\n# Input morphing parameters:\n" morphs_in += ( @@ -302,7 +301,6 @@ def get_multisave_names(target_list: list, save_names_file=None, mm=False): The names to save each morph as. Keys are the target function file names used to produce that morph. """ - # Dictionary storing save file names save_names = {} @@ -382,7 +380,6 @@ def multiple_morph_output( Multiple morphs done with a single target rather than multiple targets for a single morphed file. Swaps morph and target in the code. """ - # Input parameters used for every morph inputs = "\n# Input morphing parameters:\n" inputs += "\n".join( @@ -480,7 +477,6 @@ def tabulate_results(multiple_morph_results): Keys in tabulated_results are the table's column names and each corresponding value is a list of data for that column. """ - # We only care about the following parameters in our data tables relevant_parameters = ["Scale", "Smear", "Stretch", "Pearson", "Rw"] diff --git a/src/diffpy/morph/morphapp.py b/src/diffpy/morph/morphapp.py index 5b03a6ad..aae91b0a 100755 --- a/src/diffpy/morph/morphapp.py +++ b/src/diffpy/morph/morphapp.py @@ -242,7 +242,7 @@ def morph_error(self, msg, error): help=( "Slope of the baseline. " "For a bulk material with scale factor 1, " - "this will have value -4\u03C0 times the atomic density. " + "this will have value -4\u03c0 times the atomic density. " "Otherwise, you can estimate it by dividing the y " "position from the x position " "of the base of the first peak. " @@ -334,7 +334,8 @@ def morph_error(self, msg, error): "--noplot", action="store_false", dest="plot", - help="""Do not show a plot.""", + help="""Do not show a plot.""" + , ) group.add_option( "--mlabel", @@ -446,7 +447,9 @@ def morph_error(self, msg, error): "--reverse", dest="reverse", action="store_true", - help="""Sort from highest to lowest instead.""", + help=\ + """Sort from highest to lowest instead.""" + , ) group.add_option( "--serial-file", @@ -1278,7 +1281,7 @@ def getPDFFromFile(fn): def main(): parser = create_option_parser() - (opts, pargs) = parser.parse_args() + opts, pargs = parser.parse_args() if opts.multiple_targets: multiple_targets(parser, opts, pargs, stdout_flag=True) elif opts.multiple_morphs: diff --git a/src/diffpy/morph/morphpy.py b/src/diffpy/morph/morphpy.py index 862d388d..71a28b71 100644 --- a/src/diffpy/morph/morphpy.py +++ b/src/diffpy/morph/morphpy.py @@ -22,7 +22,7 @@ def get_args(parser, params, kwargs): else: inputs.append(f"--{key}") inputs.append(f"{value}") - (opts, pargs) = parser.parse_args(inputs) + opts, pargs = parser.parse_args(inputs) return opts, pargs diff --git a/src/diffpy/morph/morphs/__init__.py b/src/diffpy/morph/morphs/__init__.py index e66f8e3d..df08440d 100644 --- a/src/diffpy/morph/morphs/__init__.py +++ b/src/diffpy/morph/morphs/__init__.py @@ -14,7 +14,6 @@ ############################################################################## """Definition of morphs.""" - from diffpy.morph.morphs.morph import Morph # noqa: F401 from diffpy.morph.morphs.morphchain import MorphChain # noqa: F401 from diffpy.morph.morphs.morphfuncx import MorphFuncx diff --git a/src/diffpy/morph/morphs/morph.py b/src/diffpy/morph/morphs/morph.py index 8552d5d7..fb6d40b2 100644 --- a/src/diffpy/morph/morphs/morph.py +++ b/src/diffpy/morph/morphs/morph.py @@ -13,6 +13,7 @@ # ############################################################################## """Morph -- base class for defining a morph.""" + import numpy LABEL_RA = "r (A)" # r-grid @@ -189,9 +190,10 @@ def applyConfig(self, config): return def checkConfig(self): - """Verify data in self.config. No action by default. + """Verify data in self.config. - To be overridden in a derived class. + No action by default. To be overridden in a derived + class. """ return @@ -257,7 +259,6 @@ def set_extrapolation_info(self, x_true, x_extrapolate): x_extrapolate : array x values after a morphing process """ - cutoff_low = min(x_true) extrap_low_x = numpy.where(x_extrapolate < cutoff_low)[0] is_extrap_low = False if len(extrap_low_x) == 0 else True diff --git a/src/diffpy/morph/morphs/morphchain.py b/src/diffpy/morph/morphs/morphchain.py index e7a8f824..53641d8d 100644 --- a/src/diffpy/morph/morphs/morphchain.py +++ b/src/diffpy/morph/morphs/morphchain.py @@ -12,9 +12,7 @@ # See LICENSE.txt for license information. # ############################################################################## -"""MorphChain -- Chain of morphs executed in order. -""" - +"""MorphChain -- Chain of morphs executed in order.""" class MorphChain(list): """Class for chaining morphs together. diff --git a/src/diffpy/morph/morphs/morphishape.py b/src/diffpy/morph/morphs/morphishape.py index 6492b9d2..452e3ecf 100644 --- a/src/diffpy/morph/morphs/morphishape.py +++ b/src/diffpy/morph/morphs/morphishape.py @@ -15,7 +15,6 @@ """Class MorphISphere -- apply inverse spherical shape function class MorphISpheroid -- apply inverse spheroidal shape function.""" - import numpy from diffpy.morph.morphs.morph import LABEL_GR, LABEL_RA, Morph diff --git a/src/diffpy/morph/morphs/morphresolution.py b/src/diffpy/morph/morphs/morphresolution.py index eb4b65b1..5538430b 100644 --- a/src/diffpy/morph/morphs/morphresolution.py +++ b/src/diffpy/morph/morphs/morphresolution.py @@ -15,7 +15,6 @@ """Class MorphResolutionDamping -- apply resolution broadening to the morph.""" - import numpy from diffpy.morph.morphs.morph import LABEL_RA, LABEL_RR, Morph diff --git a/src/diffpy/morph/morphs/morphrgrid.py b/src/diffpy/morph/morphs/morphrgrid.py index 9b20cf67..c2dd54c4 100644 --- a/src/diffpy/morph/morphs/morphrgrid.py +++ b/src/diffpy/morph/morphs/morphrgrid.py @@ -14,7 +14,6 @@ ############################################################################## """Class MorphRGrid -- put morph and target on desired grid.""" - import numpy from diffpy.morph.morphs.morph import LABEL_GR, LABEL_RA, Morph diff --git a/src/diffpy/morph/morphs/morphscale.py b/src/diffpy/morph/morphs/morphscale.py index c2bd86c7..b02b06e6 100644 --- a/src/diffpy/morph/morphs/morphscale.py +++ b/src/diffpy/morph/morphs/morphscale.py @@ -14,7 +14,6 @@ ############################################################################## """Class MorphScale -- scale the morph data.""" - from diffpy.morph.morphs.morph import LABEL_GR, LABEL_RA, Morph diff --git a/src/diffpy/morph/morphs/morphshape.py b/src/diffpy/morph/morphs/morphshape.py index 0405f3d1..888cec9e 100644 --- a/src/diffpy/morph/morphs/morphshape.py +++ b/src/diffpy/morph/morphs/morphshape.py @@ -15,7 +15,6 @@ """Class MorphSphere -- apply a spherical shape function to the morph class MorphSpheroid -- apply a spheroidal shape function to the morph.""" - import numpy from numpy import arctan as atan from numpy import arctanh as atanh diff --git a/src/diffpy/morph/morphs/morphshift.py b/src/diffpy/morph/morphs/morphshift.py index abe5f063..366d0c78 100644 --- a/src/diffpy/morph/morphs/morphshift.py +++ b/src/diffpy/morph/morphs/morphshift.py @@ -14,7 +14,6 @@ ############################################################################## """Class MorphShift -- shift the morph.""" - import numpy from diffpy.morph.morphs.morph import LABEL_GR, LABEL_RA, Morph diff --git a/src/diffpy/morph/morphs/morphsmear.py b/src/diffpy/morph/morphs/morphsmear.py index b8735919..4ddf4d5a 100644 --- a/src/diffpy/morph/morphs/morphsmear.py +++ b/src/diffpy/morph/morphs/morphsmear.py @@ -14,7 +14,6 @@ ############################################################################## """Class MorphSmear -- smear the morph.""" - import numpy from diffpy.morph.morphs.morph import LABEL_RA, LABEL_RR, Morph diff --git a/src/diffpy/morph/morphs/morphstretch.py b/src/diffpy/morph/morphs/morphstretch.py index 21f50a68..1343f7c6 100644 --- a/src/diffpy/morph/morphs/morphstretch.py +++ b/src/diffpy/morph/morphs/morphstretch.py @@ -14,7 +14,6 @@ ############################################################################## """Class MorphStretch -- stretch the morph.""" - import numpy from diffpy.morph.morphs.morph import LABEL_GR, LABEL_RA, Morph diff --git a/src/diffpy/morph/plot.py b/src/diffpy/morph/plot.py index e10c963e..3c06009d 100644 --- a/src/diffpy/morph/plot.py +++ b/src/diffpy/morph/plot.py @@ -246,7 +246,6 @@ def plot_param(target_labels, param_list, param_name=None, field=None): When None (default) or values are non-numerical, it plots a bar chart of Rw values per file. """ - # ensure all entries in target_labels are distinct for plotting unique_labels = set() for idx in range(len(target_labels)): @@ -327,7 +326,6 @@ def truncate_func(x, fx, xmin=None, xmax=None): x, fx Returns the truncated x, fx. """ - if xmin is not None: sel = x >= xmin fx = fx[sel] diff --git a/src/diffpy/morph/refine.py b/src/diffpy/morph/refine.py index 8f1390d9..7192d7bf 100644 --- a/src/diffpy/morph/refine.py +++ b/src/diffpy/morph/refine.py @@ -12,8 +12,7 @@ # See LICENSE.txt for license information. # ############################################################################## -"""refine -- Refine a morph or morph chain -""" +"""refine -- Refine a morph or morph chain""" from numpy import array, concatenate, dot, exp, ones_like from scipy.optimize import leastsq @@ -157,7 +156,6 @@ def refine(self, *args, **kw): If the number of shared grid points between morphed function and target function is smaller than the number of parameters. """ - self.pars = args or self.chain.config.keys() config = self.chain.config diff --git a/src/diffpy/morph/tools.py b/src/diffpy/morph/tools.py index 3b56cc87..1bd563be 100644 --- a/src/diffpy/morph/tools.py +++ b/src/diffpy/morph/tools.py @@ -14,7 +14,6 @@ ############################################################################## """Tools used in morphs and morph chains.""" - import numpy from diffpy.utils.parsers.loaddata import loadData @@ -117,7 +116,6 @@ def readPDF(fname): r,gr Arrays read from data. """ - rv = loadData(fname, unpack=True) if len(rv) >= 2: return rv[:2] @@ -165,7 +163,6 @@ def case_insensitive_dictionary_search(key: str, dictionary: dict): value or None Corresponding value if key is in dictionary. None otherwise. """ - for ci_key in dictionary.keys(): if key.lower() == ci_key.lower(): key = ci_key @@ -177,8 +174,9 @@ def case_insensitive_dictionary_search(key: str, dictionary: dict): def field_sort( filepaths: list, field, reverse=False, serfile=None, get_field_values=False ): - """Sort a list of files by a field stored in header information. All - files must contain this header information. + """Sort a list of files by a field stored in header information. + + All files must contain this header information. Parameters ---------- @@ -202,7 +200,6 @@ def field_sort( Sorted list of paths. When get_fv is true, also return an associated field list. """ - # Get the field from each file files_field_values = [] if serfile is None: @@ -258,7 +255,6 @@ def get_values_from_dictionary_collection( list The found values. """ - # Store all values corresponding to the target_key into this list values = [] diff --git a/tests/debug.py b/tests/debug.py index 6497a261..a0c2a7c9 100644 --- a/tests/debug.py +++ b/tests/debug.py @@ -19,7 +19,6 @@ Exceptions raised by failed tests or other errors are not caught. """ - if __name__ == "__main__": import sys diff --git a/tests/test_morphapp.py b/tests/test_morphapp.py index a414e932..fc9bc007 100644 --- a/tests/test_morphapp.py +++ b/tests/test_morphapp.py @@ -109,7 +109,7 @@ def test_parser_errors(self, capsys, setup_parser): # ###Basic tests for any variety of morphing### # Ensure only two pargs given for morphing - (opts, pargs) = self.parser.parse_args(["toofewfiles"]) + opts, pargs = self.parser.parse_args(["toofewfiles"]) with pytest.raises(TypeError) as excinfo: single_morph(self.parser, opts, pargs, stdout_flag=False) assert "You must supply MORPHFILE and TARGETFILE." in str( @@ -118,7 +118,7 @@ def test_parser_errors(self, capsys, setup_parser): with pytest.raises(TypeError) as excinfo: multiple_targets(self.parser, opts, pargs, stdout_flag=False) assert "You must supply a FILE and DIRECTORY." in str(excinfo.value) - (opts, pargs) = self.parser.parse_args(["too", "many", "files"]) + opts, pargs = self.parser.parse_args(["too", "many", "files"]) with pytest.raises(TypeError) as excinfo: single_morph(self.parser, opts, pargs, stdout_flag=False) assert ( @@ -133,7 +133,7 @@ def test_parser_errors(self, capsys, setup_parser): ) # Make sure xmax greater than xmin - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [f"{nickel_PDF}", f"{nickel_PDF}", "--xmin", "10", "--xmax", "1"] ) with pytest.raises(ValueError) as excinfo: @@ -143,7 +143,7 @@ def test_parser_errors(self, capsys, setup_parser): # ###Tests exclusive to multiple morphs### # Make sure we save to a directory that exists # (user must create the directory if non-existing) - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [ f"{nickel_PDF}", f"{nickel_PDF}", @@ -159,12 +159,12 @@ def test_parser_errors(self, capsys, setup_parser): assert "is not a directory." in str(excinfo.value) # Ensure first parg is a FILE and second parg is a DIRECTORY - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [f"{nickel_PDF}", f"{nickel_PDF}"] ) with pytest.raises(NotADirectoryError) as excinfo: multiple_targets(self.parser, opts, pargs, stdout_flag=False) - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [f"{testsequence_dir}", f"{testsequence_dir}"] ) assert "is not a directory." in str(excinfo.value) @@ -173,7 +173,7 @@ def test_parser_errors(self, capsys, setup_parser): assert "is not a file." in str(excinfo.value) # Try sorting by non-existing field - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [f"{nickel_PDF}", f"{testsequence_dir}", "--sort-by", "fake_field"] ) with pytest.raises(KeyError) as excinfo: @@ -181,7 +181,7 @@ def test_parser_errors(self, capsys, setup_parser): assert "The requested field is missing from a file header." in str( excinfo.value ) - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [ f"{nickel_PDF}", f"{testsequence_dir}", @@ -199,7 +199,7 @@ def test_parser_errors(self, capsys, setup_parser): ) # Try plotting an unknown parameter - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [ f"{nickel_PDF}", f"{testsequence_dir}", @@ -214,7 +214,7 @@ def test_parser_errors(self, capsys, setup_parser): ) # Try plotting an unrefined parameter - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [ f"{nickel_PDF}", f"{testsequence_dir}", @@ -231,7 +231,7 @@ def test_parser_errors(self, capsys, setup_parser): ) # Pass a non-float list to squeeze - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [ f"{nickel_PDF}", f"{nickel_PDF}", @@ -245,7 +245,7 @@ def test_parser_errors(self, capsys, setup_parser): def test_morphsequence(self, setup_morphsequence): # Parse arguments sorting by field - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [ "--scale", "1", @@ -282,7 +282,7 @@ def test_morphsequence(self, setup_morphsequence): # Check using a serial file produces the same result s_file = tssf.resolve().as_posix() - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [ "--scale", "1", @@ -331,7 +331,7 @@ def gaussian(x, mu, sigma): np.savetxt(f, np.array([x_grid, g3_bl]).T) # No PDF smear (should not activate baseline slope) - (opts, _) = self.parser.parse_args( + opts, _ = self.parser.parse_args( [ "--smear", "1", @@ -347,7 +347,7 @@ def gaussian(x, mu, sigma): assert pytest.approx(smear_results["Rw"]) == 0.0 # PDF-specific smear (should activate baseline slope) - (opts, _) = self.parser.parse_args( + opts, _ = self.parser.parse_args( [ "--smear", "100", diff --git a/tests/test_morphio.py b/tests/test_morphio.py index 2eed0135..b9abc672 100644 --- a/tests/test_morphio.py +++ b/tests/test_morphio.py @@ -114,7 +114,7 @@ def test_morph_outputs(self, setup, tmp_path): tmp_succinct = tmp_path.joinpath("succinct") tmp_succinct_name = tmp_succinct.resolve().as_posix() - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [ "--multiple-targets", "--sort-by", @@ -132,7 +132,7 @@ def test_morph_outputs(self, setup, tmp_path): # Save a single succinct morph ssm = tmp_succinct.joinpath("single_succinct_morph.cgr") ssm_name = ssm.resolve().as_posix() - (opts, pargs) = self.parser.parse_args(["-s", ssm_name, "-n"]) + opts, pargs = self.parser.parse_args(["-s", ssm_name, "-n"]) pargs = [morph_file, target_file] single_morph(self.parser, opts, pargs, stdout_flag=False) @@ -152,7 +152,7 @@ def test_morph_outputs(self, setup, tmp_path): tmp_verbose = tmp_path.joinpath("verbose") tmp_verbose_name = tmp_verbose.resolve().as_posix() - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [ "--multiple-targets", "--sort-by", @@ -171,7 +171,7 @@ def test_morph_outputs(self, setup, tmp_path): # Save a single verbose morph svm = tmp_verbose.joinpath("single_verbose_morph.cgr") svm_name = svm.resolve().as_posix() - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( ["-s", svm_name, "-n", "--verbose"] ) pargs = [morph_file, target_file] @@ -198,7 +198,7 @@ def test_morph_diff_outputs(self, setup, tmp_path): tmp_diff = tmp_path.joinpath("diff") tmp_diff_name = tmp_diff.resolve().as_posix() - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [ "--multiple-targets", "--sort-by", @@ -218,7 +218,7 @@ def test_morph_diff_outputs(self, setup, tmp_path): diff_name = "single_diff_morph.cgr" diff_file = tmp_diff.joinpath(diff_name) df_name = diff_file.resolve().as_posix() - (opts, pargs) = self.parser.parse_args(["-s", df_name, "-n", "--diff"]) + opts, pargs = self.parser.parse_args(["-s", df_name, "-n", "--diff"]) pargs = [morph_file, target_file] single_morph(self.parser, opts, pargs, stdout_flag=False) @@ -249,7 +249,7 @@ def test_morphsqueeze_outputs(self, setup, tmp_path): sqr = tmp_path / "squeeze_morph_result.cgr" sqr_name = sqr.resolve().as_posix() # Note that stretch and hshift should not be considered - (opts, _) = self.parser.parse_args( + opts, _ = self.parser.parse_args( [ "--scale", "2", diff --git a/tests/test_morphpy.py b/tests/test_morphpy.py index 9ffc9589..1ac24347 100644 --- a/tests/test_morphpy.py +++ b/tests/test_morphpy.py @@ -40,7 +40,7 @@ def setup_morph(self): self.morphapp_results = {} # Parse arguments sorting by field - (opts, pargs) = self.parser.parse_args( + opts, pargs = self.parser.parse_args( [ "--scale", "1", diff --git a/tests/test_morphrgrid.py b/tests/test_morphrgrid.py index 8d85a2c2..e7567ce8 100644 --- a/tests/test_morphrgrid.py +++ b/tests/test_morphrgrid.py @@ -35,7 +35,6 @@ def _runTests(self, xyallout, morph): def testRangeInBounds(self, setup): """Selected range is within input bounds.""" - config = { "xmin": 1.0, "xmax": 2.0, @@ -53,7 +52,6 @@ def testRangeInBounds(self, setup): def testxmaxOut(self, setup): """Selected xmax is outside of input bounds.""" - config = { "xmin": 1.0, "xmax": 15.0, @@ -71,7 +69,6 @@ def testxmaxOut(self, setup): def testxminOut(self, setup): """Selected xmin is outside of input bounds.""" - config = { "xmin": 0.0, "xmax": 2.0, @@ -89,7 +86,6 @@ def testxminOut(self, setup): def testxstepOut(self, setup): """Selected xstep is outside of input bounds.""" - config = { "xmin": 1.0, "xmax": 2.0, diff --git a/tests/test_morphshape.py b/tests/test_morphshape.py index 6e309d11..33b5441f 100644 --- a/tests/test_morphshape.py +++ b/tests/test_morphshape.py @@ -81,7 +81,6 @@ def reset(self): def test_morph(self): """Check MorphSpheroid.morph() and MorphISpheroid.morph()""" - for idx in range(len(self.testfiles)): self.testfile = self.testfiles[idx] diff --git a/tests/test_morphshift.py b/tests/test_morphshift.py index 28b2d1bf..f883373a 100644 --- a/tests/test_morphshift.py +++ b/tests/test_morphshift.py @@ -94,7 +94,7 @@ def test_morphshift_extrapolate(user_filesystem, capsys, hshift, wmsg_gen): ) parser = create_option_parser() - (opts, pargs) = parser.parse_args( + opts, pargs = parser.parse_args( [ f"--hshift={hshift}", f"{morph_file.as_posix()}", @@ -127,7 +127,7 @@ def test_morphshift_no_warning(user_filesystem): ) parser = create_option_parser() - (opts, pargs) = parser.parse_args( + opts, pargs = parser.parse_args( [ "--scale=1", "--hshift=0", diff --git a/tests/test_morphsqueeze.py b/tests/test_morphsqueeze.py index 90de2a6c..0e31b6b5 100644 --- a/tests/test_morphsqueeze.py +++ b/tests/test_morphsqueeze.py @@ -165,7 +165,7 @@ def test_morphsqueeze_extrapolate(user_filesystem, squeeze_coeffs, wmsg_gen): ) parser = create_option_parser() - (opts, pargs) = parser.parse_args( + opts, pargs = parser.parse_args( [ "--squeeze", ",".join(map(str, coeffs)), @@ -203,7 +203,7 @@ def test_morphsqueeze_no_warning(user_filesystem): ) parser = create_option_parser() - (opts, pargs) = parser.parse_args( + opts, pargs = parser.parse_args( [ "--scale=1", "--squeeze", @@ -312,7 +312,7 @@ def test_squeeze_warnings(user_filesystem, squeeze_coeffs, x_morph): user_filesystem / "cwd_dir", x_morph, y_morph, x_target, y_target ) parser = create_option_parser() - (opts, pargs) = parser.parse_args( + opts, pargs = parser.parse_args( [ "--squeeze", ",".join(map(str, squeeze_coeffs)), diff --git a/tests/test_morphstretch.py b/tests/test_morphstretch.py index fb076204..ad5f6fd5 100644 --- a/tests/test_morphstretch.py +++ b/tests/test_morphstretch.py @@ -120,7 +120,7 @@ def test_morphshift_extrapolate(user_filesystem, stretch, wmsg_gen): ) parser = create_option_parser() - (opts, pargs) = parser.parse_args( + opts, pargs = parser.parse_args( [ f"--stretch={stretch}", f"{morph_file.as_posix()}", @@ -153,7 +153,7 @@ def test_morphshift_no_warning(user_filesystem): ) parser = create_option_parser() - (opts, pargs) = parser.parse_args( + opts, pargs = parser.parse_args( [ "--scale=1", "--stretch=0", diff --git a/tests/test_refine.py b/tests/test_refine.py index fe9e9937..3e5c603a 100644 --- a/tests/test_refine.py +++ b/tests/test_refine.py @@ -230,7 +230,7 @@ def test_refine_grid_bad(self, user_filesystem, capsys): run_cmd.extend([str(morph_file), str(target_file)]) run_cmd.append("-n") parser = create_option_parser() - (opts, pargs) = parser.parse_args(run_cmd) + opts, pargs = parser.parse_args(run_cmd) with pytest.raises(ValueError) as excinfo: single_morph(parser, opts, pargs, stdout_flag=False) assert expected_error_message in str(excinfo.value) diff --git a/tests/test_tools.py b/tests/test_tools.py index ee4c00c9..c6a19785 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -2,7 +2,6 @@ """Unit tests for tools.py.""" - import os from pathlib import Path From 8de0b1f1c16c5f07ed64bcac5c6e5d71d9c26f2c Mon Sep 17 00:00:00 2001 From: Sparks29032 Date: Fri, 29 May 2026 17:37:41 -0700 Subject: [PATCH 4/4] Fix black/docformatter conflict --- src/diffpy/morph/morphapp.py | 7 ++----- src/diffpy/morph/morphs/morphchain.py | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/diffpy/morph/morphapp.py b/src/diffpy/morph/morphapp.py index aae91b0a..2fac4d95 100755 --- a/src/diffpy/morph/morphapp.py +++ b/src/diffpy/morph/morphapp.py @@ -334,8 +334,7 @@ def morph_error(self, msg, error): "--noplot", action="store_false", dest="plot", - help="""Do not show a plot.""" - , + help="Do not show a plot.", ) group.add_option( "--mlabel", @@ -447,9 +446,7 @@ def morph_error(self, msg, error): "--reverse", dest="reverse", action="store_true", - help=\ - """Sort from highest to lowest instead.""" - , + help="Sort from highest to lowest instead.", ) group.add_option( "--serial-file", diff --git a/src/diffpy/morph/morphs/morphchain.py b/src/diffpy/morph/morphs/morphchain.py index 53641d8d..3a7231de 100644 --- a/src/diffpy/morph/morphs/morphchain.py +++ b/src/diffpy/morph/morphs/morphchain.py @@ -14,6 +14,9 @@ ############################################################################## """MorphChain -- Chain of morphs executed in order.""" +# Comment required to resolve black/docformatter conflict + + class MorphChain(list): """Class for chaining morphs together.