From 2453e1abb7d7d7e50f112833e71e7e58bb9553b3 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Thu, 5 Mar 2026 09:47:23 -0500 Subject: [PATCH 1/5] rm deprecated six and other deprecated python2 objects --- src/diffpy/srfit/equation/literals/abcs.py | 72 +++++++++++++++++----- 1 file changed, 57 insertions(+), 15 deletions(-) diff --git a/src/diffpy/srfit/equation/literals/abcs.py b/src/diffpy/srfit/equation/literals/abcs.py index 605bc53e..8468f419 100644 --- a/src/diffpy/srfit/equation/literals/abcs.py +++ b/src/diffpy/srfit/equation/literals/abcs.py @@ -16,14 +16,10 @@ __all__ = ["LiteralABC", "ArgumentABC", "OperatorABC"] +from abc import ABC, abstractmethod -from abc import ABCMeta, abstractmethod, abstractproperty -import six - - -@six.add_metaclass(ABCMeta) -class LiteralABC(object): +class LiteralABC(ABC): """Abstract Base Class for Literal. See Literal for usage. @@ -31,13 +27,19 @@ class LiteralABC(object): @abstractmethod def identify(self, visitor): + """Identify this literal using a visitor.""" pass @abstractmethod def getValue(self): + """Return the value of the literal.""" pass - name = abstractproperty(None, None) + @property + @abstractmethod + def name(self): + """Name of the literal.""" + pass # End class LiteralABC @@ -51,10 +53,20 @@ class ArgumentABC(LiteralABC): @abstractmethod def setValue(self, value): + """Set the value of the argument.""" pass - const = abstractproperty(None, None) - value = abstractproperty(None, None) + @property + @abstractmethod + def const(self): + """Whether the argument is constant.""" + pass + + @property + @abstractmethod + def value(self): + """Value of the argument.""" + pass # End class ArgumentABC @@ -68,14 +80,44 @@ class OperatorABC(LiteralABC): @abstractmethod def addLiteral(self, literal): + """Add a literal argument to the operator.""" + pass + + @property + @abstractmethod + def args(self): + """Arguments of the operator.""" + pass + + @property + @abstractmethod + def nin(self): + """Number of input arguments.""" pass - args = abstractproperty(None, None) - nin = abstractproperty(None, None) - nout = abstractproperty(None, None) - operation = abstractproperty(None, None) - symbol = abstractproperty(None, None) - value = abstractproperty(None, None) + @property + @abstractmethod + def nout(self): + """Number of outputs.""" + pass + + @property + @abstractmethod + def operation(self): + """Callable implementing the operator.""" + pass + + @property + @abstractmethod + def symbol(self): + """Symbol representing the operator.""" + pass + + @property + @abstractmethod + def value(self): + """Value produced by the operator.""" + pass # End class OperatorABC From c4c0b104a38571a4a397c2a0776fdd2907cabc51 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Thu, 5 Mar 2026 10:56:35 -0500 Subject: [PATCH 2/5] setValue deprecation --- docs/source/extending.rst | 2 +- src/diffpy/srfit/equation/equationmod.py | 8 +- src/diffpy/srfit/equation/literals/abcs.py | 2 +- .../srfit/equation/literals/argument.py | 8 +- src/diffpy/srfit/fitbase/constraint.py | 4 +- src/diffpy/srfit/fitbase/fitrecipe.py | 8 +- src/diffpy/srfit/fitbase/parameter.py | 38 ++++--- src/diffpy/srfit/fitbase/profile.py | 8 +- src/diffpy/srfit/interface/interface.py | 2 +- src/diffpy/srfit/pdf/basepdfgenerator.py | 2 +- src/diffpy/srfit/sas/sasparameter.py | 6 +- src/diffpy/srfit/structure/objcrystparset.py | 22 ++--- tests/test_builder.py | 12 +-- tests/test_constraint.py | 4 +- tests/test_contribution.py | 8 +- tests/test_diffpyparset.py | 10 +- tests/test_equation.py | 20 ++-- tests/test_fitrecipe.py | 24 ++--- tests/test_literals.py | 12 +-- tests/test_objcrystparset.py | 16 +-- tests/test_parameter.py | 14 +-- tests/test_pdf.py | 4 +- tests/test_recipeorganizer.py | 24 ++--- tests/test_restraint.py | 14 +-- tests/test_sas.py | 4 +- tests/test_speed.py | 98 +++++++++---------- tests/test_visitors.py | 18 ++-- tests/test_weakrefcallable.py | 4 +- 28 files changed, 206 insertions(+), 190 deletions(-) diff --git a/docs/source/extending.rst b/docs/source/extending.rst index 582add1d..164ef187 100644 --- a/docs/source/extending.rst +++ b/docs/source/extending.rst @@ -108,7 +108,7 @@ can be adapted as:: setter = SimpleAtom.set, attr = "x") Thus, when ``xpar.getValue()`` is called, it in turn calls -``SimpleAtom.get(atom, "x")``. ``xpar.setValue(value)`` calls +``SimpleAtom.get(atom, "x")``. ``xpar.set_value(value)`` calls ``SimpleAtom.set(atom, "x", value)``. If the attributes of an object cannot be accessed in one of these three ways, diff --git a/src/diffpy/srfit/equation/equationmod.py b/src/diffpy/srfit/equation/equationmod.py index dd8293ec..4a40aeb7 100644 --- a/src/diffpy/srfit/equation/equationmod.py +++ b/src/diffpy/srfit/equation/equationmod.py @@ -25,8 +25,8 @@ these! > b = Argument(name="b") > add.addLiteral(a) > add.addLiteral(b) > # make an Equation instance and pass the root > eq = Equation(root = add) > eq(a=3, b=4) # returns 7 > eq(a=2) # remembers b=4, returns 6 > -eq.a.setValue(-3) > eq.b.setValue(3) > eq() # uses last assignment of a -and b, returns 0 +eq.a.set_value(-3) > eq.b.set_value(3) > eq() # uses last assignment of +a and b, returns 0 See the class documentation for more information. """ @@ -193,14 +193,14 @@ def __call__(self, *args, **kw): if idx >= len(self.argdict): raise ValueError("Too many arguments") arg = self.args[idx] - arg.setValue(val) + arg.set_value(val) # Process kw for name, val in kw.items(): arg = self.argdict.get(name) if arg is None: raise ValueError("No argument named '%s' here" % name) - arg.setValue(val) + arg.set_value(val) self._value = self.root.getValue() return self._value diff --git a/src/diffpy/srfit/equation/literals/abcs.py b/src/diffpy/srfit/equation/literals/abcs.py index 8468f419..82c633cc 100644 --- a/src/diffpy/srfit/equation/literals/abcs.py +++ b/src/diffpy/srfit/equation/literals/abcs.py @@ -52,7 +52,7 @@ class ArgumentABC(LiteralABC): """ @abstractmethod - def setValue(self, value): + def set_value(self, value): """Set the value of the argument.""" pass diff --git a/src/diffpy/srfit/equation/literals/argument.py b/src/diffpy/srfit/equation/literals/argument.py index 60d639f2..a99fb7f1 100644 --- a/src/diffpy/srfit/equation/literals/argument.py +++ b/src/diffpy/srfit/equation/literals/argument.py @@ -37,9 +37,9 @@ class Argument(Literal, ArgumentABC): A flag indicating whether this is considered a constant. Constants may be given special treatment by the Visitors. _value - The value of the Argument. Modified with 'setValue'. + The value of the Argument. Modified with 'set_value'. value - Property for 'getValue' and 'setValue'. + Property for 'getValue' and 'set_value'. """ const = None @@ -59,7 +59,7 @@ def getValue(self): """Get the value of this Literal.""" return self._value - def setValue(self, val): + def set_value(self, val): """Set the value of the Literal. Attributes @@ -77,7 +77,7 @@ def setValue(self, val): return value = property( - lambda self: self.getValue(), lambda self, val: self.setValue(val) + lambda self: self.getValue(), lambda self, val: self.set_value(val) ) diff --git a/src/diffpy/srfit/fitbase/constraint.py b/src/diffpy/srfit/fitbase/constraint.py index 68171548..b0a89d19 100644 --- a/src/diffpy/srfit/fitbase/constraint.py +++ b/src/diffpy/srfit/fitbase/constraint.py @@ -82,7 +82,7 @@ def update(self): val = self.eq() # This will only change the Parameter if val is different from the # currently stored value. - self.par.setValue(val) + self.par.set_value(val) return def _validate(self): @@ -107,7 +107,7 @@ def _validate(self): # Try to get the value of eq. try: val = self.eq() - self.par.setValue(val) + self.par.set_value(val) except TypeError: raise SrFitError("eq cannot be evaluated") finally: diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 0aff6ecd..2ebaa777 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -759,7 +759,7 @@ def add_variable( raise ValueError("The parameter '%s' is constrained" % par) var = ParameterProxy(name, par) if value is not None: - var.setValue(value) + var.set_value(value) self._add_parameter(var) if fixed: self.fix(var) @@ -1185,7 +1185,7 @@ def constrain(self, par, con, ns={}): val = con.getValue() if val is None: val = par.getValue() - con.setValue(val) + con.set_value(val) if par in self._parameters.values(): self.fix(par) @@ -1352,7 +1352,7 @@ def _set_parameters_from_dict(self, params_dict): parameter names and values.""" for param_name, param_value in params_dict.items(): if param_name in self._parameters: - self._parameters[param_name].setValue(param_value) + self._parameters[param_name].set_value(param_value) else: print( f"Warning: Parameter '{param_name}' from results " @@ -1742,7 +1742,7 @@ def _apply_values(self, p): return vargen = (v for v in self._parameters.values() if self.is_free(v)) for var, pval in zip(vargen, p): - var.setValue(pval) + var.set_value(pval) return def _update_configuration(self): diff --git a/src/diffpy/srfit/fitbase/parameter.py b/src/diffpy/srfit/fitbase/parameter.py index d7887f7d..1c7450d7 100644 --- a/src/diffpy/srfit/fitbase/parameter.py +++ b/src/diffpy/srfit/fitbase/parameter.py @@ -34,6 +34,13 @@ from diffpy.srfit.interface import _parameter_interface from diffpy.srfit.util.argbinders import bind2nd from diffpy.srfit.util.nameutils import validateName +from diffpy.utils._deprecator import build_deprecation_message, deprecated + +parameter_base = "diffpy.srfit.fitbase.Parameter" +removal_version = "4.0.0" +setValue_dep_msg = build_deprecation_message( + parameter_base, "setValue", "set_value", removal_version +) class Parameter(_parameter_interface, Argument, Validatable): @@ -46,9 +53,9 @@ class Parameter(_parameter_interface, Argument, Validatable): const A flag indicating whether this is considered a constant. _value - The value of the Parameter. Modified with 'setValue'. + The value of the Parameter. Modified with 'set_value'. value - Property for 'getValue' and 'setValue'. + Property for 'getValue' and 'set_value'. constrained A flag indicating if the Parameter is constrained (default False). @@ -81,7 +88,7 @@ def __init__(self, name, value=None, const=False): Argument.__init__(self, name, value, const) return - def setValue(self, val): + def set_value(self, val): """Set the value of the Parameter and the bounds. Attributes @@ -100,9 +107,18 @@ def setValue(self, val): self Returns self so that mutators can be chained. """ - Argument.setValue(self, val) + Argument.set_value(self, val) return self + @deprecated(setValue_dep_msg) + def setValue(self, val): + """This function has been deprecated and will be removed in + version 4.0.0. + + Please use diffpy.srfit.fitbase.Parameter.set_value instead. + """ + return self.set_value(val) + def setConst(self, const=True, value=None): """Toggle the Parameter as constant. @@ -123,7 +139,7 @@ def setConst(self, const=True, value=None): """ self.const = bool(const) if value is not None: - self.setValue(value) + self.set_value(value) return self def boundRange(self, lb=None, ub=None): @@ -254,9 +270,9 @@ def _observers(self): # wrap Parameter methods to use the target object ------------------------ - @wraps(Parameter.setValue) - def setValue(self, val): - return self.par.setValue(val) + @wraps(Parameter.set_value) + def set_value(self, val): + return self.par.set_value(val) @wraps(Parameter.getValue) def getValue(self): @@ -293,8 +309,8 @@ def _validate(self): class ParameterAdapter(Parameter): """An adapter for parameter-like objects. - This class wraps an object as a Parameter. The getValue and setValue - methods defer to the data of the wrapped object. + This class wraps an object as a Parameter. The getValue and + set_value methods defer to the data of the wrapped object. """ def __init__(self, name, obj, getter=None, setter=None, attr=None): @@ -359,7 +375,7 @@ def getValue(self): """Get the value of the Parameter.""" return self.getter(self.obj) - def setValue(self, value): + def set_value(self, value): """Set the value of the Parameter.""" if value != self.getValue(): self.setter(self.obj, value) diff --git a/src/diffpy/srfit/fitbase/profile.py b/src/diffpy/srfit/fitbase/profile.py index ae4e896b..684a0313 100644 --- a/src/diffpy/srfit/fitbase/profile.py +++ b/src/diffpy/srfit/fitbase/profile.py @@ -136,19 +136,19 @@ def __init__(self): # We want x, y, ycalc and dy to stay in-sync with xpar, ypar and dypar x = property( lambda self: self.xpar.getValue(), - lambda self, val: self.xpar.setValue(val), + lambda self, val: self.xpar.set_value(val), ) y = property( lambda self: self.ypar.getValue(), - lambda self, val: self.ypar.setValue(val), + lambda self, val: self.ypar.set_value(val), ) dy = property( lambda self: self.dypar.getValue(), - lambda self, val: self.dypar.setValue(val), + lambda self, val: self.dypar.set_value(val), ) ycalc = property( lambda self: self.ycpar.getValue(), - lambda self, val: self.ycpar.setValue(val), + lambda self, val: self.ycpar.set_value(val), ) # We want xobs, yobs and dyobs to be read-only diff --git a/src/diffpy/srfit/interface/interface.py b/src/diffpy/srfit/interface/interface.py index 71e1b20e..308e0471 100644 --- a/src/diffpy/srfit/interface/interface.py +++ b/src/diffpy/srfit/interface/interface.py @@ -36,7 +36,7 @@ class ParameterInterface(object): """Mix-in class for enhancing the Parameter interface.""" def __lshift__(self, v): - """SetValue with << + """set_value with << Think of '<<' as injecting a value diff --git a/src/diffpy/srfit/pdf/basepdfgenerator.py b/src/diffpy/srfit/pdf/basepdfgenerator.py index 9b915be7..d19005cf 100644 --- a/src/diffpy/srfit/pdf/basepdfgenerator.py +++ b/src/diffpy/srfit/pdf/basepdfgenerator.py @@ -174,7 +174,7 @@ def processMetaData(self): val = self.meta.get(name) if val is not None: par = self.get(name) - par.setValue(val) + par.set_value(val) return diff --git a/src/diffpy/srfit/sas/sasparameter.py b/src/diffpy/srfit/sas/sasparameter.py index ad3d9895..28ae4834 100644 --- a/src/diffpy/srfit/sas/sasparameter.py +++ b/src/diffpy/srfit/sas/sasparameter.py @@ -33,9 +33,9 @@ class SASParameter(Parameter): const A flag indicating whether this is considered a constant. _value - The value of the Parameter. Modified with 'setValue'. + The value of the Parameter. Modified with 'set_value'. value - Property for 'getValue' and 'setValue'. + Property for 'getValue' and 'set_value'. constrained A flag indicating if the Parameter is constrained (default False). @@ -73,7 +73,7 @@ def getValue(self): value = self._model.getParam(self._parname) return value - def setValue(self, value): + def set_value(self, value): """Set the value of the Parameter.""" if value != self.getValue(): self._model.setParam(self._parname, value) diff --git a/src/diffpy/srfit/structure/objcrystparset.py b/src/diffpy/srfit/structure/objcrystparset.py index 62995ee6..f50650b6 100644 --- a/src/diffpy/srfit/structure/objcrystparset.py +++ b/src/diffpy/srfit/structure/objcrystparset.py @@ -1153,7 +1153,7 @@ def __init__(self, name, value=None, const=False): Parameter.__init__(self, name, value, const) self.keepcenter = True - def setValue(self, val): + def set_value(self, val): """Change the value of the Parameter.""" curval = self.getValue() val = float(val) @@ -1166,7 +1166,7 @@ def setValue(self, val): self.mode.Stretch(delta, self.keepcenter) # Let Parameter take care of the general details - Parameter.setValue(self, val) + Parameter.set_value(self, val) return self @@ -1268,9 +1268,9 @@ class ObjCrystBondLengthParameter(StretchModeParameter): const A flag indicating whether this is considered a constant. _value - The value of the Parameter. Modified with 'setValue'. + The value of the Parameter. Modified with 'set_value'. value - Property for 'getValue' and 'setValue'. + Property for 'getValue' and 'set_value'. constraint A callable that calculates the value of this Parameter. If this is None (None), the the Parameter is responsible for its @@ -1363,7 +1363,7 @@ def getValue(self): """ if self._value is None: val = GetBondLength(self.atom1.scat, self.atom2.scat) - Parameter.setValue(self, val) + Parameter.set_value(self, val) return self._value @@ -1406,9 +1406,9 @@ class ObjCrystBondAngleParameter(StretchModeParameter): const A flag indicating whether this is considered a constant. _value - The value of the Parameter. Modified with 'setValue'. + The value of the Parameter. Modified with 'set_value'. value - Property for 'getValue' and 'setValue'. + Property for 'getValue' and 'set_value'. constraint A callable that calculates the value of this Parameter. If this is None (None), the the Parameter is responsible for its @@ -1509,7 +1509,7 @@ def getValue(self): val = GetBondAngle( self.atom1.scat, self.atom2.scat, self.atom3.scat ) - Parameter.setValue(self, val) + Parameter.set_value(self, val) return self._value @@ -1557,9 +1557,9 @@ class ObjCrystDihedralAngleParameter(StretchModeParameter): const A flag indicating whether this is considered a constant. _value - The value of the Parameter. Modified with 'setValue'. + The value of the Parameter. Modified with 'set_value'. value - Property for 'getValue' and 'setValue'. + Property for 'getValue' and 'set_value'. constraint A callable that calculates the value of this Parameter. If this is None (None), the the Parameter is responsible for its @@ -1676,7 +1676,7 @@ def getValue(self): self.atom3.scat, self.atom4.scat, ) - Parameter.setValue(self, val) + Parameter.set_value(self, val) return self._value diff --git a/tests/test_builder.py b/tests/test_builder.py index da1f56f6..0cdf6d20 100644 --- a/tests/test_builder.py +++ b/tests/test_builder.py @@ -153,10 +153,10 @@ def testParseEquation(noObserversInGlobalBuilders): x = numpy.pi B = 4.0 C = 2.0 - eq.A.setValue(A) - eq.x.setValue(x) - eq.B.setValue(B) - eq.C.setValue(C) + eq.A.set_value(A) + eq.x.set_value(x) + eq.B.set_value(B) + eq.C.set_value(C) assert numpy.array_equal(eq(), f_equation(A, x, B, C)) # Make sure that the arguments of eq are listed in the order in which @@ -167,8 +167,8 @@ def testParseEquation(noObserversInGlobalBuilders): eq = factory.makeEquation("sqrt(e**(-0.5*(x/sigma)**2))") x = numpy.arange(0, 1, 0.05) sigma = 0.1 - eq.x.setValue(x) - eq.sigma.setValue(sigma) + eq.x.set_value(x) + eq.sigma.set_value(sigma) assert numpy.allclose(eq(), gaussian_test(x, sigma)) assert eq.args == [eq.x, eq.sigma] diff --git a/tests/test_constraint.py b/tests/test_constraint.py index 5c41689f..00da5b14 100644 --- a/tests/test_constraint.py +++ b/tests/test_constraint.py @@ -50,11 +50,11 @@ def testConstraint(self): eq3 = equationFromString("p1", factory) self.assertRaises(ValueError, c2.constrain, p2, eq3) - p2.setValue(2.5) + p2.set_value(2.5) c.update() self.assertEqual(5.0, p1.getValue()) - p2.setValue(8.1) + p2.set_value(8.1) self.assertEqual(5.0, p1.getValue()) c.update() self.assertEqual(16.2, p1.getValue()) diff --git a/tests/test_contribution.py b/tests/test_contribution.py index ef388b6b..e30bf7c4 100644 --- a/tests/test_contribution.py +++ b/tests/test_contribution.py @@ -198,7 +198,7 @@ def test_registerFunction(self): fc = self.fitcontribution fc.registerFunction(_fsquare, name="fsquare") fc.set_equation("fsquare") - fc.x.setValue(5) + fc.x.set_value(5) self.assertEqual(25, fc.evaluate()) fc.x << 6 self.assertEqual(36, fc.evaluate()) @@ -257,7 +257,7 @@ def testResidual(noObserversInGlobalBuilders): assert dot(chiv, chiv) == pytest.approx(dot(yobs, yobs)) # Try something more complex - c.setValue(3) + c.set_value(3) fc.set_equation("c**2*sin(I)") assert fc._eq._value is None assert fc._reseq._value is None @@ -300,7 +300,7 @@ def test_setEquation(noObserversInGlobalBuilders): """Check replacement of removed parameters.""" fc = FitContribution("test") fc.setEquation("x + 5") - fc.x.setValue(2) + fc.x.set_value(2) assert 7 == fc.evaluate() fc.removeParameter(fc.x) x = arange(0, 10, 0.5) @@ -314,7 +314,7 @@ def test_set_equation(noObserversInGlobalBuilders): """Check replacement of removed parameters.""" fc = FitContribution("test") fc.set_equation("x + 5") - fc.x.setValue(2) + fc.x.set_value(2) assert 7 == fc.evaluate() fc.removeParameter(fc.x) x = arange(0, 10, 0.5) diff --git a/tests/test_diffpyparset.py b/tests/test_diffpyparset.py index 8463d80d..2e523d35 100644 --- a/tests/test_diffpyparset.py +++ b/tests/test_diffpyparset.py @@ -90,12 +90,12 @@ def _testLattice(): _testLattice() # Now change values from the srfit DiffpyStructureParSet - s.Cu0.x.setValue(0.456) - s.Cu0.U22.setValue(0.441) - s.Cu0.B13.setValue(0.550) + s.Cu0.x.set_value(0.456) + s.Cu0.U22.set_value(0.441) + s.Cu0.B13.set_value(0.550) d = dsstru.lattice.dist(a1.xyz, a2.xyz) - s.lattice.b.setValue(4.6) - s.lattice.alpha.setValue(91.3) + s.lattice.b.set_value(4.6) + s.lattice.alpha.set_value(91.3) _testAtoms() _testLattice() # Make sure the distance changed diff --git a/tests/test_equation.py b/tests/test_equation.py index ff44a3d8..c4bc7cd8 100644 --- a/tests/test_equation.py +++ b/tests/test_equation.py @@ -46,11 +46,11 @@ def testSimpleFunction(make_args, noObserversInGlobalBuilders): # Set the values of the variables. # The equation should evaluate to 2.5*(1+3)*(4-2) = 20 - v1.setValue(1) - v2.setValue(2) - v3.setValue(3) - v4.setValue(4) - c.setValue(2.5) + v1.set_value(1) + v2.set_value(2) + v3.set_value(3) + v4.set_value(4) + c.set_value(2.5) # Make an equation and test eq = Equation("eq", mult2) @@ -135,11 +135,11 @@ def testEmbeddedEquation(make_args, noObserversInGlobalBuilders): # Set the values of the variables. # The equation should evaluate to 2.5*(1+3)*(4-2) = 20 - v1.setValue(1) - v2.setValue(2) - v3.setValue(3) - v4.setValue(4) - c.setValue(2.5) + v1.set_value(1) + v2.set_value(2) + v3.set_value(3) + v4.set_value(4) + c.set_value(2.5) # Make an equation and test root = Equation("root", mult2) diff --git a/tests/test_fitrecipe.py b/tests/test_fitrecipe.py index bc5cff21..4c928431 100644 --- a/tests/test_fitrecipe.py +++ b/tests/test_fitrecipe.py @@ -49,9 +49,9 @@ def setUp(self): self.fitcontribution = FitContribution("cont") self.fitcontribution.set_profile(self.profile) self.fitcontribution.set_equation("A*sin(k*x + c)") - self.fitcontribution.A.setValue(1) - self.fitcontribution.k.setValue(1) - self.fitcontribution.c.setValue(0) + self.fitcontribution.A.set_value(1) + self.fitcontribution.k.set_value(1) + self.fitcontribution.c.set_value(0) self.recipe.add_contribution(self.fitcontribution) return @@ -208,7 +208,7 @@ def testResidual(self): # Change the c value to 1 so that the equation evaluates as sin(x+1) x = self.profile.x y = sin(x + 1) - self.recipe.cont.c.setValue(1) + self.recipe.cont.c.set_value(1) res = self.recipe.residual() self.assertTrue(array_equal(y - self.profile.y, res)) @@ -241,7 +241,7 @@ def testResidual(self): # Clear the constraint and restore the value of c to 0. This should # give us chi2 = 0 again. self.recipe.unconstrain(self.fitcontribution.c) - self.fitcontribution.c.setValue(0) + self.fitcontribution.c.set_value(0) res = self.recipe.residual([self.recipe.cont.A.getValue()]) chi2 = 0 self.assertAlmostEqual(chi2, dot(res, res)) @@ -276,7 +276,7 @@ def testResidual(self): self.fitcontribution.unrestrain(r1) self.recipe._ready = False self.fitcontribution.unconstrain(self.fitcontribution.c) - self.fitcontribution.c.setValue(0) + self.fitcontribution.c.set_value(0) res = self.recipe.residual() chi2 = 0 self.assertAlmostEqual(chi2, dot(res, res)) @@ -354,9 +354,9 @@ def testPrintFitHook(capturestdout): fitcontribution = FitContribution("cont") fitcontribution.set_profile(profile) fitcontribution.set_equation("A*sin(k*x + c)") - fitcontribution.A.setValue(1) - fitcontribution.k.setValue(1) - fitcontribution.c.setValue(0) + fitcontribution.A.set_value(1) + fitcontribution.k.set_value(1) + fitcontribution.c.set_value(0) recipe.addContribution(fitcontribution) @@ -430,9 +430,9 @@ def test_add_contribution(capturestdout): fitcontribution = FitContribution("cont") fitcontribution.set_profile(profile) fitcontribution.set_equation("A*sin(k*x + c)") - fitcontribution.A.setValue(1) - fitcontribution.k.setValue(1) - fitcontribution.c.setValue(0) + fitcontribution.A.set_value(1) + fitcontribution.k.set_value(1) + fitcontribution.c.set_value(0) recipe.add_contribution(fitcontribution) diff --git a/tests/test_literals.py b/tests/test_literals.py index 8155d64a..970a2702 100644 --- a/tests/test_literals.py +++ b/tests/test_literals.py @@ -49,10 +49,10 @@ def testValue(self): self.assertEqual(None, a.getValue()) # Test setting value - a.setValue(3.14) + a.set_value(3.14) self.assertAlmostEqual(3.14, a._value) - a.setValue(3.14) + a.set_value(3.14) self.assertAlmostEqual(3.14, a.value) self.assertAlmostEqual(3.14, a.getValue()) return @@ -100,7 +100,7 @@ def testValue(self): self.assertAlmostEqual(0, op.value) # Test update from the nodes - a.setValue(4) + a.set_value(4) self.assertTrue(op._value is None) self.assertAlmostEqual(4, op.value) self.assertAlmostEqual(4, op.getValue()) @@ -129,11 +129,11 @@ def testAddLiteral(self): op.addLiteral(b) self.assertAlmostEqual(0, op.value) - a.setValue(1) - b.setValue(2) + a.set_value(1) + b.set_value(2) self.assertAlmostEqual(3, op.value) - a.setValue(None) + a.set_value(None) # Test for self-references # Try to add self diff --git a/tests/test_objcrystparset.py b/tests/test_objcrystparset.py index 10c96ee9..f905a9eb 100644 --- a/tests/test_objcrystparset.py +++ b/tests/test_objcrystparset.py @@ -223,11 +223,11 @@ def _testMolecule(): _testMolecule() # Now change values from the srfit StructureParSet - cryst.c60.C44.x.setValue(1.1) - cryst.c60.C44.occ.setValue(1.1) - cryst.c60.C44.Biso.setValue(1.1) - cryst.c60.q3.setValue(1.1) - cryst.a.setValue(1.1) + cryst.c60.C44.x.set_value(1.1) + cryst.c60.C44.occ.set_value(1.1) + cryst.c60.C44.Biso.set_value(1.1) + cryst.c60.q3.set_value(1.1) + cryst.a.set_value(1.1) _testCrystal() _testMolecule() @@ -411,7 +411,7 @@ def testExplicitBondLengthParameter(self): # Change the value scale = 1.05 - p1.setValue(scale * d0) + p1.set_value(scale * d0) # Verify that it has changed. assert scale * d0 == pytest.approx(p1.getValue(), abs=1e-6) @@ -483,7 +483,7 @@ def testExplicitBondAngleParameter(self): # Change the value scale = 1.05 - p1.setValue(scale * angle0) + p1.set_value(scale * angle0) # Verify that it has changed. assert scale * angle0 == pytest.approx(p1.getValue(), abs=1e-6) @@ -564,7 +564,7 @@ def testExplicitDihedralAngleParameter(self): # Change the value scale = 1.05 - p1.setValue(scale * angle0) + p1.set_value(scale * angle0) # Verify that it has changed. assert scale * angle0 == pytest.approx(p1.getValue(), abs=1e-6) diff --git a/tests/test_parameter.py b/tests/test_parameter.py index 04ecd4c7..90606179 100644 --- a/tests/test_parameter.py +++ b/tests/test_parameter.py @@ -29,7 +29,7 @@ def testSetValue(self): """Test initialization.""" par_l = Parameter("l") - par_l.setValue(3.14) + par_l.set_value(3.14) self.assertAlmostEqual(3.14, par_l.getValue()) # Try array @@ -47,7 +47,7 @@ def testSetValue(self): self.assertTrue(par_l.value is y) # Back to scalar - par_l.setValue(1.01) + par_l.set_value(1.01) self.assertAlmostEqual(1.01, par_l.getValue()) self.assertAlmostEqual(1.01, par_l.value) return @@ -89,18 +89,18 @@ def testWrapper(self): # Try Accessor adaptation la = ParameterAdapter( - "l", par_l, getter=Parameter.getValue, setter=Parameter.setValue + "l", par_l, getter=Parameter.getValue, setter=Parameter.set_value ) self.assertEqual(par_l.name, la.name) self.assertEqual(par_l.getValue(), la.getValue()) # Change the parameter - par_l.setValue(2.3) + par_l.set_value(2.3) self.assertEqual(par_l.getValue(), la.getValue()) # Change the adapter - la.setValue(3.2) + la.set_value(3.2) self.assertEqual(par_l.getValue(), la.getValue()) # Try Attribute adaptation @@ -111,11 +111,11 @@ def testWrapper(self): self.assertEqual(par_l.getValue(), la.getValue()) # Change the parameter - par_l.setValue(2.3) + par_l.set_value(2.3) self.assertEqual(par_l.getValue(), la.getValue()) # Change the adapter - la.setValue(3.2) + la.set_value(3.2) self.assertEqual(par_l.getValue(), la.getValue()) return diff --git a/tests/test_pdf.py b/tests/test_pdf.py index b46fa2a6..37839b01 100644 --- a/tests/test_pdf.py +++ b/tests/test_pdf.py @@ -173,9 +173,9 @@ def testGenerator( defval = calc._getDoubleAttr(pname) assert defval == par.getValue() # Test setting values - par.setValue(1.0) + par.set_value(1.0) assert 1.0 == par.getValue() - par.setValue(defval) + par.set_value(defval) assert defval == par.getValue() r = numpy.arange(0, 10, 0.1) diff --git a/tests/test_recipeorganizer.py b/tests/test_recipeorganizer.py index a5db1e1b..15a284af 100644 --- a/tests/test_recipeorganizer.py +++ b/tests/test_recipeorganizer.py @@ -275,7 +275,7 @@ def testConstrain(self): self.assertEqual(1, len(self.m._constraints)) self.assertTrue(self.m.isConstrained(p1)) - p2.setValue(10) + p2.set_value(10) self.m._constraints[p1].update() self.assertEqual(20, p1.getValue()) @@ -291,7 +291,7 @@ def testConstrain(self): # Try an straight constraint self.m.constrain(p1, p2) - p2.setValue(7) + p2.set_value(7) self.m._constraints[p1].update() self.assertEqual(7, p1.getValue()) return @@ -308,14 +308,14 @@ def testRestrain(self): self.assertEqual(0, len(self.m._restraints)) r = self.m.restrain("p1+p2", ub=10) self.assertEqual(1, len(self.m._restraints)) - p2.setValue(10) + p2.set_value(10) self.assertEqual(1, r.penalty()) self.m.unrestrain(r) self.assertEqual(0, len(self.m._restraints)) r = self.m.restrain(p1, ub=10) self.assertEqual(1, len(self.m._restraints)) - p1.setValue(11) + p1.set_value(11) self.assertEqual(1, r.penalty()) # Check errors on unregistered parameters @@ -401,15 +401,15 @@ def __call__(self, x): self.m.registerCalculator(g) x = numpy.arange(0.5, 10, 0.5) - self.m.x.setValue(x) + self.m.x.set_value(x) - self.m.g.center.setValue(3.0) + self.m.g.center.set_value(3.0) self.assertTrue( numpy.array_equal(numpy.exp(-0.5 * ((x - 3.0) / 0.1) ** 2), g(x)) ) - self.m.g.center.setValue(5.0) + self.m.g.center.set_value(5.0) self.assertTrue( numpy.array_equal(numpy.exp(-0.5 * ((x - 5.0) / 0.1) ** 2), g(x)) @@ -437,10 +437,10 @@ def g2(A): self.assertTrue(p in self.m._parameters.values()) x = numpy.arange(0.5, 10, 0.5) - self.m.x.setValue(x) - self.m.A.setValue(1.0) - self.m.c.setValue(3.0) - self.m.w.setValue(0.1) + self.m.x.set_value(x) + self.m.A.set_value(1.0) + self.m.c.set_value(3.0) + self.m.w.set_value(0.1) self.assertTrue( numpy.array_equal(numpy.exp(-0.5 * ((x - 3.0) / 0.1) ** 2), eq()) @@ -477,7 +477,7 @@ def testRegisterStringFunction(self): # Make an equation. eq1 = self.m.registerStringFunction("x**2 + 3", "eq1") - eq1.x.setValue(0) + eq1.x.set_value(0) for p in eq1.args: self.assertTrue(p in self.m._parameters.values()) diff --git a/tests/test_restraint.py b/tests/test_restraint.py index 68673679..c5ef55c7 100644 --- a/tests/test_restraint.py +++ b/tests/test_restraint.py @@ -40,20 +40,20 @@ def testRestraint(self): r = Restraint(eq, 1, 5) # This should have no penalty - p1.setValue(1) - p2.setValue(1) + p1.set_value(1) + p2.set_value(1) self.assertEqual(0, r.penalty()) # Make p1 + p2 = 0 # This should have a penalty of 1*(1 - 0)**2 = 1 - p1.setValue(-1) - p2.setValue(1) + p1.set_value(-1) + p2.set_value(1) self.assertEqual(1, r.penalty()) # Make p1 + p2 = 8 # This should have a penalty of 1*(8 - 5)**2 = 9 - p1.setValue(4) - p2.setValue(4) + p1.set_value(4) + p2.set_value(4) self.assertEqual(9, r.penalty()) # Set the chi^2 to get a dynamic penalty @@ -64,7 +64,7 @@ def testRestraint(self): import numpy r.ub = numpy.inf - p1.setValue(1e100) + p1.set_value(1e100) self.assertEqual(0, r.penalty()) return diff --git a/tests/test_sas.py b/tests/test_sas.py index 59cb14c0..db856942 100644 --- a/tests/test_sas.py +++ b/tests/test_sas.py @@ -123,10 +123,10 @@ def test_generator(sas_available): par = gen.get(pname) assert defval == par.getValue() # Test setting values - par.setValue(1.0) + par.set_value(1.0) assert 1.0 == par.getValue() assert 1.0 == model.getParam(pname) - par.setValue(defval) + par.set_value(defval) assert defval == par.getValue() assert defval == model.getParam(pname) diff --git a/tests/test_speed.py b/tests/test_speed.py index 6bc75014..5c2d7f3a 100644 --- a/tests/test_speed.py +++ b/tests/test_speed.py @@ -52,19 +52,19 @@ def makeLazyEquation(make_args): mult2.addLiteral(pow) mult2.addLiteral(exp) - v2.setValue(x) - v3.setValue(50 * x) - v5.setValue(2.11) - v6.setValue(numpy.e) + v2.set_value(x) + v3.set_value(50 * x) + v5.set_value(2.11) + v6.set_value(numpy.e) evaluator = visitors.Evaluator() def _f(a, b, c, d, e): - v1.setValue(a) - v4.setValue(b) - v5.setValue(c) - v6.setValue(d) - v7.setValue(e) + v1.set_value(a) + v4.set_value(b) + v5.set_value(c) + v6.set_value(d) + v7.set_value(e) mult2.identify(evaluator) evaluator.clicker.click() return evaluator.value @@ -133,18 +133,18 @@ def speedTest2(mutate=2): """ factory.registerConstant("x", x) eq = factory.makeEquation(eqstr) - eq.qsig.setValue(qsig) - eq.sigma1.setValue(sigma) - eq.sigma2.setValue(sigma) - eq.A0.setValue(1.0) - eq.b1.setValue(0) - eq.b2.setValue(1) - eq.b3.setValue(2.0) - eq.b4.setValue(2.0) - eq.b5.setValue(2.0) - eq.b6.setValue(2.0) - eq.b7.setValue(2.0) - eq.b8.setValue(2.0) + eq.qsig.set_value(qsig) + eq.sigma1.set_value(sigma) + eq.sigma2.set_value(sigma) + eq.A0.set_value(1.0) + eq.b1.set_value(0) + eq.b2.set_value(1) + eq.b3.set_value(2.0) + eq.b4.set_value(2.0) + eq.b5.set_value(2.0) + eq.b6.set_value(2.0) + eq.b7.set_value(2.0) + eq.b8.set_value(2.0) from numpy import exp, polyval @@ -211,18 +211,18 @@ def speedTest3(mutate=2): """ factory.registerConstant("x", x) eq = factory.makeEquation(eqstr) - eq.qsig.setValue(qsig) - eq.sigma1.setValue(sigma) - eq.sigma2.setValue(sigma) - eq.A0.setValue(1.0) - eq.b1.setValue(0) - eq.b2.setValue(1) - eq.b3.setValue(2.0) - eq.b4.setValue(2.0) - eq.b5.setValue(2.0) - eq.b6.setValue(2.0) - eq.b7.setValue(2.0) - eq.b8.setValue(2.0) + eq.qsig.set_value(qsig) + eq.sigma1.set_value(sigma) + eq.sigma2.set_value(sigma) + eq.A0.set_value(1.0) + eq.b1.set_value(0) + eq.b2.set_value(1) + eq.b3.set_value(2.0) + eq.b4.set_value(2.0) + eq.b5.set_value(2.0) + eq.b6.set_value(2.0) + eq.b7.set_value(2.0) + eq.b8.set_value(2.0) from numpy import polyval from sympy import exp, lambdify, var @@ -357,14 +357,14 @@ def weightedTest(mutate=2): factory.registerConstant("x", x) eq = factory.makeEquation(eqstr) - eq.b1.setValue(0) - eq.b2.setValue(1) - eq.b3.setValue(2.0) - eq.b4.setValue(2.0) - eq.b5.setValue(2.0) - eq.b6.setValue(2.0) - eq.b7.setValue(2.0) - eq.b8.setValue(2.0) + eq.b1.set_value(0) + eq.b2.set_value(1) + eq.b3.set_value(2.0) + eq.b4.set_value(2.0) + eq.b5.set_value(2.0) + eq.b6.set_value(2.0) + eq.b7.set_value(2.0) + eq.b8.set_value(2.0) # scale = visitors.NodeWeigher() # eq.root.identify(scale) @@ -426,14 +426,14 @@ def profileTest(): factory.registerConstant("x", x) eq = factory.makeEquation(eqstr) - eq.b1.setValue(0) - eq.b2.setValue(1) - eq.b3.setValue(2.0) - eq.b4.setValue(2.0) - eq.b5.setValue(2.0) - eq.b6.setValue(2.0) - eq.b7.setValue(2.0) - eq.b8.setValue(2.0) + eq.b1.set_value(0) + eq.b2.set_value(1) + eq.b3.set_value(2.0) + eq.b4.set_value(2.0) + eq.b5.set_value(2.0) + eq.b6.set_value(2.0) + eq.b7.set_value(2.0) + eq.b8.set_value(2.0) mutate = 8 numargs = len(eq.args) diff --git a/tests/test_visitors.py b/tests/test_visitors.py index 546edaaa..9ae8698d 100644 --- a/tests/test_visitors.py +++ b/tests/test_visitors.py @@ -117,10 +117,10 @@ def testSimpleFunction(self): # Set the values of the variables. # The equation should evaluate to (1+3)*(4-2) = 8 - v1.setValue(1) - v2.setValue(2) - v3.setValue(3) - v4.setValue(4) + v1.set_value(1) + v2.set_value(2) + v3.set_value(3) + v4.set_value(4) # now get the args args = visitors.getArgs(mult) @@ -170,11 +170,11 @@ def testSimpleFunction(self): # Set the values of the variables. # The equation should evaluate to (1+3)*(4-2) = 8 - v1.setValue(1) - v2.setValue(2) - v3.setValue(3) - v4.setValue(4) - v5.setValue(5) + v1.set_value(1) + v2.set_value(2) + v3.set_value(3) + v4.set_value(4) + v5.set_value(5) # Evaluate assert 8 == mult.value diff --git a/tests/test_weakrefcallable.py b/tests/test_weakrefcallable.py index fd3488ac..1e8ca092 100644 --- a/tests/test_weakrefcallable.py +++ b/tests/test_weakrefcallable.py @@ -119,7 +119,7 @@ def test_observable_deregistration(self): xof = next(iter(x._observers)) self.assertTrue(isinstance(xof, WeakBoundMethod)) # changing value of x should reset f._eq - x.setValue(x.value + 1) + x.set_value(x.value + 1) self.assertTrue(None is f._eq._value) self.assertEqual(18, f.evaluate()) # deallocate f now @@ -127,7 +127,7 @@ def test_observable_deregistration(self): self.assertTrue(xof in x._observers) # since f does not exist anymore, the next notification call # should drop the associated observer. - x.setValue(x.value + 1) + x.set_value(x.value + 1) self.assertEqual(0, len(x._observers)) return From 6d0de2732ba722bdc7c998d41395dd5f0961b3c6 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Thu, 5 Mar 2026 10:57:53 -0500 Subject: [PATCH 3/5] news --- news/setvalue-dep.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/setvalue-dep.rst diff --git a/news/setvalue-dep.rst b/news/setvalue-dep.rst new file mode 100644 index 00000000..83121f06 --- /dev/null +++ b/news/setvalue-dep.rst @@ -0,0 +1,23 @@ +**Added:** + +* Added ``set_value`` method to ``diffpy.srfit.fitbase.Parameter``. + +**Changed:** + +* + +**Deprecated:** + +* Deprecated ``setValue`` method in ``diffpy.srfit.fitbase.Parameter`` for removal in 4.0.0. + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 314b155e4ebf580e25b29669670f650f25e8136b Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Fri, 6 Mar 2026 11:15:26 -0500 Subject: [PATCH 4/5] skip test_speed.py --- tests/test_speed.py | 59 ++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/tests/test_speed.py b/tests/test_speed.py index 5c2d7f3a..e859e4e0 100644 --- a/tests/test_speed.py +++ b/tests/test_speed.py @@ -17,14 +17,23 @@ import random import numpy +import pytest import diffpy.srfit.equation.literals as literals import diffpy.srfit.equation.visitors as visitors +pytestmark = pytest.mark.skip( + reason=( + "This is a performance benchmark test, " + "not a unit test. Comment out this line " + "to run performance testing." + ) +) + x = numpy.arange(0, 20, 0.05) -def makeLazyEquation(make_args): +def make_lazy_equation(make_args): """Make a lazy equation and see how fast it is.""" # Make some variables @@ -72,7 +81,7 @@ def _f(a, b, c, d, e): return _f -def makeEquation1(): +def make_equation1(): """Make the same equation as the lazy one.""" y = 50 * x @@ -83,7 +92,7 @@ def _f(a, b, c, d, e): return _f -def timeFunction(f, *args, **kw): +def time_function(f, *args, **kw): """Time a function in ms.""" import time @@ -93,9 +102,9 @@ def timeFunction(f, *args, **kw): return (t2 - t1) * 1000 -def speedTest1(): - f1 = makeLazyEquation() - f2 = makeEquation1() +def test_speed1(): + f1 = make_lazy_equation() + f2 = make_equation1() args = [3.1, 8.19973123410, 2.1, numpy.e, numpy.pi] @@ -104,8 +113,8 @@ def speedTest1(): for i in range(len(args)): args[i] = 10 * random.random() print("Changing argument %i" % (i + 1)) - t1 = timeFunction(f1, *args) - t2 = timeFunction(f2, *args) + t1 = time_function(f1, *args) + t2 = time_function(f2, *args) total1 += t1 total2 += t2 print("lazy", t1) @@ -117,7 +126,7 @@ def speedTest1(): print("Ratio (lazy/regular)", total1 / total2) -def speedTest2(mutate=2): +def test_speed2(mutate=2): from diffpy.srfit.equation.builder import EquationFactory @@ -176,8 +185,8 @@ def f(A0, qsig, sigma1, sigma2, b1, b2, b3, b4, b5, b6, b7, b8): args[idx] = random.random() # Time the different functions with these arguments - tnpy += timeFunction(f, *args) - teq += timeFunction(eq, *args) + tnpy += time_function(f, *args) + teq += time_function(eq, *args) print( "Average call time (%i calls, %i mutations/call):" % (numcalls, mutate) @@ -189,7 +198,7 @@ def f(A0, qsig, sigma1, sigma2, b1, b2, b3, b4, b5, b6, b7, b8): return -def speedTest3(mutate=2): +def test_speed3(mutate=2): """Test wrt sympy. Results - sympy is 10 to 24 times faster without using arrays (ouch!). @@ -265,8 +274,8 @@ def speedTest3(mutate=2): args[idx] = random.random() # Time the different functions with these arguments - teq += timeFunction(eq, *(args[:-1])) - tnpy += timeFunction(f, *args) + teq += time_function(eq, *(args[:-1])) + tnpy += time_function(f, *args) print( "Average call time (%i calls, %i mutations/call):" % (numcalls, mutate) @@ -278,7 +287,7 @@ def speedTest3(mutate=2): return -def speedTest4(mutate=2): +def test_speed4(mutate=2): """Test wrt sympy. Results - sympy is 10 to 24 times faster without using arrays (ouch!). @@ -310,7 +319,7 @@ def speedTest4(mutate=2): teq = 0 # Randomly change variables numargs = len(eq.args) - choices = range(numargs) + choices = list(range(numargs)) args = [1.0] * (len(eq.args)) args.append(x) @@ -329,8 +338,8 @@ def speedTest4(mutate=2): args[idx] = random.random() # Time the different functions with these arguments - teq += timeFunction(eq, *(args[:-1])) - tnpy += timeFunction(f, *args) + teq += time_function(eq, *(args[:-1])) + tnpy += time_function(f, *args) print( "Average call time (%i calls, %i mutations/call):" % (numcalls, mutate) @@ -342,7 +351,7 @@ def speedTest4(mutate=2): return -def weightedTest(mutate=2): +def test_weighted(mutate=2): """Show the benefits of a properly balanced equation tree.""" from diffpy.srfit.equation.builder import EquationFactory @@ -379,7 +388,7 @@ def f(b1, b2, b3, b4, b5, b6, b7, b8): teq = 0 # Randomly change variables numargs = len(eq.args) - choices = range(numargs) + choices = list(range(numargs)) args = [0.1] * numargs # The call-loop @@ -399,8 +408,8 @@ def f(b1, b2, b3, b4, b5, b6, b7, b8): # print(args) # Time the different functions with these arguments - teq += timeFunction(eq, *args) - tnpy += timeFunction(f, *args) + teq += time_function(eq, *args) + tnpy += time_function(f, *args) print( "Average call time (%i calls, %i mutations/call):" % (numcalls, mutate) @@ -412,9 +421,9 @@ def f(b1, b2, b3, b4, b5, b6, b7, b8): return -def profileTest(): +def test_profile(): - from diffpy.srfit.builder import EquationFactory + from diffpy.srfit.equation.builder import EquationFactory factory = EquationFactory() @@ -437,7 +446,7 @@ def profileTest(): mutate = 8 numargs = len(eq.args) - choices = range(numargs) + choices = list(range(numargs)) args = [0.1] * numargs # The call-loop From bb99611056bc4a1de5275accef688ad1fa5784fa Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Fri, 6 Mar 2026 12:38:01 -0500 Subject: [PATCH 5/5] ignore test_speed.py in codecov --- .codecov.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.codecov.yml b/.codecov.yml index 4af5eb24..1cdcf2e9 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -5,6 +5,9 @@ coverage: target: auto # use the coverage from the base commit, fail if coverage is lower threshold: 0% # allow the coverage to drop by + ignore: + - "tests/test_speed.py" # ignore performance testing in test coverage. + comment: layout: " diff, flags, files" behavior: default