From 1ce94dd2482faf6e67ea4f184733d768358e4298 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Sun, 22 Feb 2026 14:27:25 -0500 Subject: [PATCH 01/13] isFree deprecation --- src/diffpy/srfit/fitbase/fitrecipe.py | 27 +++++++++++++----- tests/test_fitrecipe.py | 40 +++++++++++++-------------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 5c9ef5f1..91039657 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -99,6 +99,10 @@ base, "newVar", "create_new_variable", removal_version ) +isFree_dep_msg = build_deprecation_message( + base, "isFree", "is_free", removal_version +) + class FitRecipe(_fitrecipe_interface, RecipeOrganizer): """FitRecipe class. @@ -169,7 +173,7 @@ class FitRecipe(_fitrecipe_interface, RecipeOrganizer): lambda self: [ v.name for v in self._parameters.values() - if not (self.isFree(v) or self.isConstrained(v)) + if not (self.is_free(v) or self.isConstrained(v)) ], doc="names of the fixed refinable variables", ) @@ -178,7 +182,7 @@ class FitRecipe(_fitrecipe_interface, RecipeOrganizer): [ v.value for v in self._parameters.values() - if not (self.isFree(v) or self.isConstrained(v)) + if not (self.is_free(v) or self.isConstrained(v)) ] ), doc="values of the fixed refinable variables", @@ -935,10 +939,19 @@ def free(self, *args, **kw): return - def isFree(self, var): + def is_free(self, var): """Check if a variable is fixed.""" return not self._tagmanager.hasTags(var, self._fixedtag) + @deprecated(isFree_dep_msg) + def isFree(self, var): + """This function has been deprecated and will be removed in version + 4.0.0. + + Please use diffpy.srfit.fitbase.FitRecipe.is_free instead. + """ + return self.is_free(var) + def unconstrain(self, *pars): """Unconstrain a Parameter. @@ -1037,12 +1050,12 @@ def constrain(self, par, con, ns={}): def getValues(self): """Get the current values of the variables in a list.""" return array( - [v.value for v in self._parameters.values() if self.isFree(v)] + [v.value for v in self._parameters.values() if self.is_free(v)] ) def getNames(self): """Get the names of the variables in a list.""" - return [v.name for v in self._parameters.values() if self.isFree(v)] + return [v.name for v in self._parameters.values() if self.is_free(v)] def getBounds(self): """Get the bounds on variables in a list. @@ -1050,7 +1063,7 @@ def getBounds(self): Returns a list of (lb, ub) pairs, where lb is the lower bound and ub is the upper bound. """ - return [v.bounds for v in self._parameters.values() if self.isFree(v)] + return [v.bounds for v in self._parameters.values() if self.is_free(v)] def getBounds2(self): """Get the bounds on variables in two lists. @@ -1372,7 +1385,7 @@ def _apply_values(self, p): """Apply variable values to the variables.""" if len(p) == 0: return - vargen = (v for v in self._parameters.values() if self.isFree(v)) + vargen = (v for v in self._parameters.values() if self.is_free(v)) for var, pval in zip(vargen, p): var.setValue(pval) return diff --git a/tests/test_fitrecipe.py b/tests/test_fitrecipe.py index 0391c991..7230032d 100644 --- a/tests/test_fitrecipe.py +++ b/tests/test_fitrecipe.py @@ -54,7 +54,7 @@ def setUp(self): self.recipe.add_contribution(self.fitcontribution) return - def testFixFree(self): + def test_fix_free(self): recipe = self.recipe con = self.fitcontribution @@ -63,36 +63,36 @@ def testFixFree(self): recipe.add_variable(con.c, 0) recipe.create_new_variable("B", 0) - self.assertTrue(recipe.isFree(recipe.A)) + self.assertTrue(recipe.is_free(recipe.A)) recipe.fix("tagA") - self.assertFalse(recipe.isFree(recipe.A)) + self.assertFalse(recipe.is_free(recipe.A)) recipe.free("tagA") - self.assertTrue(recipe.isFree(recipe.A)) + self.assertTrue(recipe.is_free(recipe.A)) recipe.fix("A") - self.assertFalse(recipe.isFree(recipe.A)) + self.assertFalse(recipe.is_free(recipe.A)) recipe.free("A") - self.assertTrue(recipe.isFree(recipe.A)) + self.assertTrue(recipe.is_free(recipe.A)) recipe.fix(recipe.A) - self.assertFalse(recipe.isFree(recipe.A)) + self.assertFalse(recipe.is_free(recipe.A)) recipe.free(recipe.A) - self.assertTrue(recipe.isFree(recipe.A)) + self.assertTrue(recipe.is_free(recipe.A)) recipe.fix(recipe.A) - self.assertFalse(recipe.isFree(recipe.A)) + self.assertFalse(recipe.is_free(recipe.A)) recipe.free("all") - self.assertTrue(recipe.isFree(recipe.A)) - self.assertTrue(recipe.isFree(recipe.k)) - self.assertTrue(recipe.isFree(recipe.c)) - self.assertTrue(recipe.isFree(recipe.B)) + self.assertTrue(recipe.is_free(recipe.A)) + self.assertTrue(recipe.is_free(recipe.k)) + self.assertTrue(recipe.is_free(recipe.c)) + self.assertTrue(recipe.is_free(recipe.B)) recipe.fix(recipe.A, "tagk", c=3) - self.assertFalse(recipe.isFree(recipe.A)) - self.assertFalse(recipe.isFree(recipe.k)) - self.assertFalse(recipe.isFree(recipe.c)) - self.assertTrue(recipe.isFree(recipe.B)) + self.assertFalse(recipe.is_free(recipe.A)) + self.assertFalse(recipe.is_free(recipe.k)) + self.assertFalse(recipe.is_free(recipe.c)) + self.assertTrue(recipe.is_free(recipe.B)) self.assertEqual(3, recipe.c.value) recipe.fix("all") - self.assertFalse(recipe.isFree(recipe.A)) - self.assertFalse(recipe.isFree(recipe.k)) - self.assertFalse(recipe.isFree(recipe.c)) + self.assertFalse(recipe.is_free(recipe.A)) + self.assertFalse(recipe.is_free(recipe.k)) + self.assertFalse(recipe.is_free(recipe.c)) self.assertFalse(recipe.isFree(recipe.B)) self.assertRaises(ValueError, recipe.free, "junk") From eef890c52381bb841f24bd790fb2c01f75ba94ce Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Sun, 22 Feb 2026 14:37:23 -0500 Subject: [PATCH 02/13] getValues deprecation --- docs/examples/debyemodelII.py | 2 +- docs/examples/gaussianrecipe.py | 4 +-- docs/examples/nppdfobjcryst.py | 2 +- docs/examples/threedoublepeaks.py | 4 +-- src/diffpy/srfit/fitbase/calculator.py | 2 +- src/diffpy/srfit/fitbase/fitcontribution.py | 2 +- src/diffpy/srfit/fitbase/fithook.py | 2 +- src/diffpy/srfit/fitbase/fitrecipe.py | 16 +++++++++-- src/diffpy/srfit/fitbase/fitresults.py | 2 +- src/diffpy/srfit/fitbase/parameterset.py | 2 +- src/diffpy/srfit/fitbase/profilegenerator.py | 2 +- src/diffpy/srfit/fitbase/recipeorganizer.py | 30 +++++++++++++++++--- src/diffpy/srfit/fitbase/simplerecipe.py | 2 +- tests/test_fitrecipe.py | 18 ++++++------ 14 files changed, 62 insertions(+), 28 deletions(-) diff --git a/docs/examples/debyemodelII.py b/docs/examples/debyemodelII.py index 631c4143..a7c896cb 100644 --- a/docs/examples/debyemodelII.py +++ b/docs/examples/debyemodelII.py @@ -98,7 +98,7 @@ def plotResults(recipe): # The variable values are returned in the order in which the variables were # added to the FitRecipe. - lowToffset, highToffset, thetaD = recipe.getValues() + lowToffset, highToffset, thetaD = recipe.get_values() # We want to extend the fitting range to its full extent so we can get a # nice full plot. diff --git a/docs/examples/gaussianrecipe.py b/docs/examples/gaussianrecipe.py index 7bf85355..fde45cc5 100644 --- a/docs/examples/gaussianrecipe.py +++ b/docs/examples/gaussianrecipe.py @@ -172,11 +172,11 @@ def scipyOptimize(recipe): # 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 - # (recipe.getValues()). + # (recipe.get_values()). from scipy.optimize.minpack import leastsq print("Fit using scipy's LM optimizer") - leastsq(recipe.residual, recipe.getValues()) + leastsq(recipe.residual, recipe.get_values()) return diff --git a/docs/examples/nppdfobjcryst.py b/docs/examples/nppdfobjcryst.py index 50dd9f79..70426101 100644 --- a/docs/examples/nppdfobjcryst.py +++ b/docs/examples/nppdfobjcryst.py @@ -143,7 +143,7 @@ def main(): # Optimize from scipy.optimize import leastsq - leastsq(recipe.residual, recipe.getValues()) + leastsq(recipe.residual, recipe.get_values()) # Print results res = FitResults(recipe) diff --git a/docs/examples/threedoublepeaks.py b/docs/examples/threedoublepeaks.py index 99eb4e92..8ad75304 100644 --- a/docs/examples/threedoublepeaks.py +++ b/docs/examples/threedoublepeaks.py @@ -179,11 +179,11 @@ def scipyOptimize(recipe): # 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 - # (recipe.getValues()). + # (recipe.get_values()). from scipy.optimize.minpack import leastsq print("Fit using scipy's LM optimizer") - leastsq(recipe.residual, recipe.getValues()) + leastsq(recipe.residual, recipe.get_values()) return diff --git a/src/diffpy/srfit/fitbase/calculator.py b/src/diffpy/srfit/fitbase/calculator.py index 75083b4e..d8762fad 100644 --- a/src/diffpy/srfit/fitbase/calculator.py +++ b/src/diffpy/srfit/fitbase/calculator.py @@ -79,7 +79,7 @@ class Calculator(Operator, ParameterSet): names Variable names (read only). See getNames. values - Variable values (read only). See getValues. + Variable values (read only). See get_values. """ # define abstract attributes from the Operator base. diff --git a/src/diffpy/srfit/fitbase/fitcontribution.py b/src/diffpy/srfit/fitbase/fitcontribution.py index c9e3df9c..ec84db7a 100644 --- a/src/diffpy/srfit/fitbase/fitcontribution.py +++ b/src/diffpy/srfit/fitbase/fitcontribution.py @@ -127,7 +127,7 @@ class FitContribution(ParameterSet): names Variable names (read only). See getNames. values - Variable values (read only). See getValues. + Variable values (read only). See get_values. """ def __init__(self, name): diff --git a/src/diffpy/srfit/fitbase/fithook.py b/src/diffpy/srfit/fitbase/fithook.py index be8cdf7c..438bbfd4 100644 --- a/src/diffpy/srfit/fitbase/fithook.py +++ b/src/diffpy/srfit/fitbase/fithook.py @@ -165,7 +165,7 @@ def postcall(self, recipe, chiv): if self.verbose >= 3: print("Variables") vnames = recipe.getNames() - vals = recipe.getValues() + vals = recipe.get_values() # byname = _byname() items = sorted(zip(vnames, vals), key=_byname) for name, val in items: diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 91039657..da262d3c 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -103,6 +103,10 @@ base, "isFree", "is_free", removal_version ) +getValues_dep_msg = build_deprecation_message( + base, "getValues", "get_values", removal_version +) + class FitRecipe(_fitrecipe_interface, RecipeOrganizer): """FitRecipe class. @@ -158,7 +162,7 @@ class FitRecipe(_fitrecipe_interface, RecipeOrganizer): names Variable names (read only). See getNames. values - Variable values (read only). See getValues. + Variable values (read only). See get_values. fixednames Names of the fixed refinable variables (read only). fixedvalues @@ -1047,12 +1051,20 @@ def constrain(self, par, con, ns={}): RecipeOrganizer.constrain(self, par, con, ns) return - def getValues(self): + def get_values(self): """Get the current values of the variables in a list.""" return array( [v.value for v in self._parameters.values() if self.is_free(v)] ) + @deprecated(getValues_dep_msg) + def getValues(self): + """This function has been deprecated and will be removed in version + 4.0.0. + + Please use diffpy.srfit.fitbase.FitRecipe.get_values instead.""" + return self.get_values() + def getNames(self): """Get the names of the variables in a list.""" return [v.name for v in self._parameters.values() if self.is_free(v)] diff --git a/src/diffpy/srfit/fitbase/fitresults.py b/src/diffpy/srfit/fitbase/fitresults.py index 1949526a..4a05acfb 100644 --- a/src/diffpy/srfit/fitbase/fitresults.py +++ b/src/diffpy/srfit/fitbase/fitresults.py @@ -153,7 +153,7 @@ def update(self): # Store the variable names and values self.varnames = recipe.getNames() - self.varvals = recipe.getValues() + self.varvals = recipe.get_values() fixedpars = recipe._tagmanager.union(recipe._fixedtag) fixedpars = [p for p in fixedpars if not p.constrained] self.fixednames = [p.name for p in fixedpars] diff --git a/src/diffpy/srfit/fitbase/parameterset.py b/src/diffpy/srfit/fitbase/parameterset.py index 6d200ca9..5c689583 100644 --- a/src/diffpy/srfit/fitbase/parameterset.py +++ b/src/diffpy/srfit/fitbase/parameterset.py @@ -77,7 +77,7 @@ class ParameterSet(RecipeOrganizer): names Variable names (read only). See getNames. values - Variable values (read only). See getValues. + Variable values (read only). See get_values. """ def __init__(self, name): diff --git a/src/diffpy/srfit/fitbase/profilegenerator.py b/src/diffpy/srfit/fitbase/profilegenerator.py index c6adabbc..64636d98 100644 --- a/src/diffpy/srfit/fitbase/profilegenerator.py +++ b/src/diffpy/srfit/fitbase/profilegenerator.py @@ -112,7 +112,7 @@ class ProfileGenerator(Operator, ParameterSet): names Variable names (read only). See getNames. values - Variable values (read only). See getValues. + Variable values (read only). See get_values. """ # define abstract attributes from the Operator base. diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index 3b95a216..96ca668e 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -42,6 +42,17 @@ from diffpy.srfit.util import sortKeyForNumericString as numstr from diffpy.srfit.util.nameutils import validateName from diffpy.srfit.util.observable import Observable +from diffpy.utils._deprecator import build_deprecation_message, deprecated + +base = "diffpy.srfit.fitbase.recipeorganizer.RecipeOrganizer" +removal_version = "4.0.0" + +getValues_deprecation_msg = build_deprecation_message( + base, + "getValues", + "get_values", + removal_version, +) class RecipeContainer(Observable, Configurable, Validatable): @@ -85,11 +96,11 @@ class RecipeContainer(Observable, Configurable, Validatable): names Variable names (read only). See getNames. values - Variable values (read only). See getValues. + Variable values (read only). See get_values. """ names = property(lambda self: self.getNames()) - values = property(lambda self: self.getValues()) + values = property(lambda self: self.get_values()) def __init__(self, name): Observable.__init__(self) @@ -233,10 +244,21 @@ def getNames(self): """Get the names of managed parameters.""" return [p.name for p in self._parameters.values()] - def getValues(self): + def get_values(self): """Get the values of managed parameters.""" return [p.value for p in self._parameters.values()] + @deprecated(getValues_deprecation_msg) + def getValues(self): + """This function has been deprecated and will be removed in version + 4.0.0. + + Please use + diffpy.srfit.fitbase.recipeorganizer.RecipeContainer.get_values + instead. + """ + return self.get_values() + def _add_object(self, obj, d, check=True): """Add an object to a managed dictionary. @@ -402,7 +424,7 @@ class RecipeOrganizer(_recipeorganizer_interface, RecipeContainer): names Variable names (read only). See getNames. values - Variable values (read only). See getValues. + Variable values (read only). See get_values. Raises ValueError if the name is not a valid attribute identifier diff --git a/src/diffpy/srfit/fitbase/simplerecipe.py b/src/diffpy/srfit/fitbase/simplerecipe.py index 36391e86..8f2edd70 100644 --- a/src/diffpy/srfit/fitbase/simplerecipe.py +++ b/src/diffpy/srfit/fitbase/simplerecipe.py @@ -123,7 +123,7 @@ class SimpleRecipe(FitRecipe): names Variable names (read only). See getNames. values - Variable values (read only). See getValues. + Variable values (read only). See get_values. """ def __init__(self, name="fit", conclass=FitContribution): diff --git a/tests/test_fitrecipe.py b/tests/test_fitrecipe.py index 7230032d..a3ab9f0a 100644 --- a/tests/test_fitrecipe.py +++ b/tests/test_fitrecipe.py @@ -112,13 +112,13 @@ def test_variables(self): names = recipe.getNames() self.assertEqual(names, ["A", "k", "c", "B"]) - values = recipe.getValues() + values = recipe.get_values() self.assertTrue((values == [2, 1, 0, 0]).all()) # Constrain a parameter to the B-variable to give it a value p = Parameter("Bpar", -1) recipe.constrain(recipe.B, p) - values = recipe.getValues() + values = recipe.get_values() self.assertTrue((values == [2, 1, 0]).all()) recipe.delete_variable(recipe.B) @@ -126,13 +126,13 @@ def test_variables(self): names = recipe.getNames() self.assertEqual(names, ["A", "c"]) - values = recipe.getValues() + values = recipe.get_values() self.assertTrue((values == [2, 0]).all()) recipe.fix("all") names = recipe.getNames() self.assertEqual(names, []) - values = recipe.getValues() + values = recipe.get_values() self.assertTrue((values == []).all()) recipe.free("all") @@ -141,7 +141,7 @@ def test_variables(self): self.assertTrue("A" in names) self.assertTrue("k" in names) self.assertTrue("c" in names) - values = recipe.getValues() + values = recipe.get_values() self.assertEqual(3, len(values)) self.assertTrue(0 in values) self.assertTrue(1 in values) @@ -160,13 +160,13 @@ def testVars(self): names = recipe.getNames() self.assertEqual(names, ["A", "k", "c", "B"]) - values = recipe.getValues() + values = recipe.get_values() self.assertTrue((values == [2, 1, 0, 0]).all()) # Constrain a parameter to the B-variable to give it a value p = Parameter("Bpar", -1) recipe.constrain(recipe.B, p) - values = recipe.getValues() + values = recipe.get_values() self.assertTrue((values == [2, 1, 0]).all()) recipe.delVar(recipe.B) @@ -174,13 +174,13 @@ def testVars(self): names = recipe.getNames() self.assertEqual(names, ["A", "c"]) - values = recipe.getValues() + values = recipe.get_values() self.assertTrue((values == [2, 0]).all()) recipe.fix("all") names = recipe.getNames() self.assertEqual(names, []) - values = recipe.getValues() + values = recipe.get_values() self.assertTrue((values == []).all()) recipe.free("all") From f26302f720c14396734320610332f21a7f94862a Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Sun, 22 Feb 2026 14:39:03 -0500 Subject: [PATCH 03/13] fix typo in base name --- src/diffpy/srfit/fitbase/recipeorganizer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index 96ca668e..1a4466ff 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -44,7 +44,7 @@ from diffpy.srfit.util.observable import Observable from diffpy.utils._deprecator import build_deprecation_message, deprecated -base = "diffpy.srfit.fitbase.recipeorganizer.RecipeOrganizer" +base = "diffpy.srfit.fitbase.recipeorganizer.RecipeContainer" removal_version = "4.0.0" getValues_deprecation_msg = build_deprecation_message( From fd6bc73f16f7b6de715f6092e76c5511323c3b16 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Sun, 22 Feb 2026 14:44:28 -0500 Subject: [PATCH 04/13] getNames deprecation --- src/diffpy/srfit/fitbase/calculator.py | 2 +- src/diffpy/srfit/fitbase/fitcontribution.py | 2 +- src/diffpy/srfit/fitbase/fithook.py | 2 +- src/diffpy/srfit/fitbase/fitrecipe.py | 16 +++++++++-- src/diffpy/srfit/fitbase/fitresults.py | 2 +- src/diffpy/srfit/fitbase/parameterset.py | 2 +- src/diffpy/srfit/fitbase/profilegenerator.py | 2 +- src/diffpy/srfit/fitbase/recipeorganizer.py | 30 ++++++++++++++++---- src/diffpy/srfit/fitbase/simplerecipe.py | 2 +- tests/test_fitrecipe.py | 14 ++++----- 10 files changed, 52 insertions(+), 22 deletions(-) diff --git a/src/diffpy/srfit/fitbase/calculator.py b/src/diffpy/srfit/fitbase/calculator.py index d8762fad..22e96540 100644 --- a/src/diffpy/srfit/fitbase/calculator.py +++ b/src/diffpy/srfit/fitbase/calculator.py @@ -77,7 +77,7 @@ class Calculator(Operator, ParameterSet): Properties ---------- names - Variable names (read only). See getNames. + Variable names (read only). See get_names. values Variable values (read only). See get_values. """ diff --git a/src/diffpy/srfit/fitbase/fitcontribution.py b/src/diffpy/srfit/fitbase/fitcontribution.py index ec84db7a..d6ff6ed0 100644 --- a/src/diffpy/srfit/fitbase/fitcontribution.py +++ b/src/diffpy/srfit/fitbase/fitcontribution.py @@ -125,7 +125,7 @@ class FitContribution(ParameterSet): Properties ---------- names - Variable names (read only). See getNames. + Variable names (read only). See get_names. values Variable values (read only). See get_values. """ diff --git a/src/diffpy/srfit/fitbase/fithook.py b/src/diffpy/srfit/fitbase/fithook.py index 438bbfd4..b5b284c5 100644 --- a/src/diffpy/srfit/fitbase/fithook.py +++ b/src/diffpy/srfit/fitbase/fithook.py @@ -164,7 +164,7 @@ def postcall(self, recipe, chiv): if self.verbose >= 3: print("Variables") - vnames = recipe.getNames() + vnames = recipe.get_names() vals = recipe.get_values() # byname = _byname() items = sorted(zip(vnames, vals), key=_byname) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index da262d3c..a13b2fe0 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -107,6 +107,10 @@ base, "getValues", "get_values", removal_version ) +getNames_dep_msg = build_deprecation_message( + base, "getNames", "get_names", removal_version +) + class FitRecipe(_fitrecipe_interface, RecipeOrganizer): """FitRecipe class. @@ -160,7 +164,7 @@ class FitRecipe(_fitrecipe_interface, RecipeOrganizer): Properties ---------- names - Variable names (read only). See getNames. + Variable names (read only). See get_names. values Variable values (read only). See get_values. fixednames @@ -1065,10 +1069,18 @@ def getValues(self): Please use diffpy.srfit.fitbase.FitRecipe.get_values instead.""" return self.get_values() - def getNames(self): + def get_names(self): """Get the names of the variables in a list.""" return [v.name for v in self._parameters.values() if self.is_free(v)] + @deprecated(getNames_dep_msg) + def getNames(self): + """This function has been deprecated and will be removed in version + 4.0.0. + + Please use diffpy.srfit.fitbase.FitRecipe.get_names instead.""" + return self.get_names() + def getBounds(self): """Get the bounds on variables in a list. diff --git a/src/diffpy/srfit/fitbase/fitresults.py b/src/diffpy/srfit/fitbase/fitresults.py index 4a05acfb..c79c2a17 100644 --- a/src/diffpy/srfit/fitbase/fitresults.py +++ b/src/diffpy/srfit/fitbase/fitresults.py @@ -152,7 +152,7 @@ def update(self): recipe._prepare() # Store the variable names and values - self.varnames = recipe.getNames() + self.varnames = recipe.get_names() self.varvals = recipe.get_values() fixedpars = recipe._tagmanager.union(recipe._fixedtag) fixedpars = [p for p in fixedpars if not p.constrained] diff --git a/src/diffpy/srfit/fitbase/parameterset.py b/src/diffpy/srfit/fitbase/parameterset.py index 5c689583..e5e51e39 100644 --- a/src/diffpy/srfit/fitbase/parameterset.py +++ b/src/diffpy/srfit/fitbase/parameterset.py @@ -75,7 +75,7 @@ class ParameterSet(RecipeOrganizer): Properties ---------- names - Variable names (read only). See getNames. + Variable names (read only). See get_names. values Variable values (read only). See get_values. """ diff --git a/src/diffpy/srfit/fitbase/profilegenerator.py b/src/diffpy/srfit/fitbase/profilegenerator.py index 64636d98..c45e93aa 100644 --- a/src/diffpy/srfit/fitbase/profilegenerator.py +++ b/src/diffpy/srfit/fitbase/profilegenerator.py @@ -110,7 +110,7 @@ class ProfileGenerator(Operator, ParameterSet): Properties ---------- names - Variable names (read only). See getNames. + Variable names (read only). See get_names. values Variable values (read only). See get_values. """ diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index 1a4466ff..ca7b273b 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -44,16 +44,23 @@ from diffpy.srfit.util.observable import Observable from diffpy.utils._deprecator import build_deprecation_message, deprecated -base = "diffpy.srfit.fitbase.recipeorganizer.RecipeContainer" +recipecontainer_base = "diffpy.srfit.fitbase.recipeorganizer.RecipeContainer" removal_version = "4.0.0" getValues_deprecation_msg = build_deprecation_message( - base, + recipecontainer_base, "getValues", "get_values", removal_version, ) +getNames_deprecation_msg = build_deprecation_message( + recipecontainer_base, + "getNames", + "get_names", + removal_version, +) + class RecipeContainer(Observable, Configurable, Validatable): """Base class for organizing pieces of a FitRecipe. @@ -94,12 +101,12 @@ class RecipeContainer(Observable, Configurable, Validatable): Properties ---------- names - Variable names (read only). See getNames. + Variable names (read only). See get_names. values Variable values (read only). See get_values. """ - names = property(lambda self: self.getNames()) + names = property(lambda self: self.get_names()) values = property(lambda self: self.get_values()) def __init__(self, name): @@ -240,10 +247,21 @@ def get(self, name, default=None): return default - def getNames(self): + def get_names(self): """Get the names of managed parameters.""" return [p.name for p in self._parameters.values()] + @deprecated(getNames_deprecation_msg) + def getNames(self): + """This function has been deprecated and will be removed in version + 4.0.0. + + Please use + diffpy.srfit.fitbase.recipeorganizer.RecipeContainer.get_names + instead. + """ + return self.get_names() + def get_values(self): """Get the values of managed parameters.""" return [p.value for p in self._parameters.values()] @@ -422,7 +440,7 @@ class RecipeOrganizer(_recipeorganizer_interface, RecipeContainer): Properties ---------- names - Variable names (read only). See getNames. + Variable names (read only). See get_names. values Variable values (read only). See get_values. diff --git a/src/diffpy/srfit/fitbase/simplerecipe.py b/src/diffpy/srfit/fitbase/simplerecipe.py index 8f2edd70..048520af 100644 --- a/src/diffpy/srfit/fitbase/simplerecipe.py +++ b/src/diffpy/srfit/fitbase/simplerecipe.py @@ -121,7 +121,7 @@ class SimpleRecipe(FitRecipe): Properties ---------- names - Variable names (read only). See getNames. + Variable names (read only). See get_names. values Variable values (read only). See get_values. """ diff --git a/tests/test_fitrecipe.py b/tests/test_fitrecipe.py index a3ab9f0a..ae466c96 100644 --- a/tests/test_fitrecipe.py +++ b/tests/test_fitrecipe.py @@ -110,7 +110,7 @@ def test_variables(self): recipe.add_variable(con.c, 0) recipe.create_new_variable("B", 0) - names = recipe.getNames() + names = recipe.get_names() self.assertEqual(names, ["A", "k", "c", "B"]) values = recipe.get_values() self.assertTrue((values == [2, 1, 0, 0]).all()) @@ -124,19 +124,19 @@ def test_variables(self): recipe.fix(recipe.k) - names = recipe.getNames() + names = recipe.get_names() self.assertEqual(names, ["A", "c"]) values = recipe.get_values() self.assertTrue((values == [2, 0]).all()) recipe.fix("all") - names = recipe.getNames() + names = recipe.get_names() self.assertEqual(names, []) values = recipe.get_values() self.assertTrue((values == []).all()) recipe.free("all") - names = recipe.getNames() + names = recipe.get_names() self.assertEqual(3, len(names)) self.assertTrue("A" in names) self.assertTrue("k" in names) @@ -158,7 +158,7 @@ def testVars(self): recipe.addVar(con.c, 0) recipe.newVar("B", 0) - names = recipe.getNames() + names = recipe.get_names() self.assertEqual(names, ["A", "k", "c", "B"]) values = recipe.get_values() self.assertTrue((values == [2, 1, 0, 0]).all()) @@ -172,13 +172,13 @@ def testVars(self): recipe.fix(recipe.k) - names = recipe.getNames() + names = recipe.get_names() self.assertEqual(names, ["A", "c"]) values = recipe.get_values() self.assertTrue((values == [2, 0]).all()) recipe.fix("all") - names = recipe.getNames() + names = recipe.get_names() self.assertEqual(names, []) values = recipe.get_values() self.assertTrue((values == []).all()) From ba3bc20ffb993ddd705136cd333f393625846450 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Sun, 22 Feb 2026 15:39:47 -0500 Subject: [PATCH 05/13] getBounds deprecation --- src/diffpy/srfit/fitbase/fitrecipe.py | 29 +++++++++++++++++++++------ src/diffpy/srfit/fitbase/parameter.py | 4 ++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index a13b2fe0..70050983 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -111,6 +111,10 @@ base, "getNames", "get_names", removal_version ) +getBounds_dep_msg = build_deprecation_message( + base, "getBounds", "get_bounds_pairs", removal_version +) + class FitRecipe(_fitrecipe_interface, RecipeOrganizer): """FitRecipe class. @@ -172,7 +176,7 @@ class FitRecipe(_fitrecipe_interface, RecipeOrganizer): fixedvalues Values of the fixed refinable variables (read only). bounds - Bounds on parameters (read only). See getBounds. + Bounds on parameters (read only). See get_bounds_pairs. bounds2 Bounds on parameters (read only). See getBounds2. """ @@ -195,7 +199,7 @@ class FitRecipe(_fitrecipe_interface, RecipeOrganizer): ), doc="values of the fixed refinable variables", ) - bounds = property(lambda self: self.getBounds()) + bounds = property(lambda self: self.get_bounds_pairs()) bounds2 = property(lambda self: self.getBounds2()) def __init__(self, name="fit"): @@ -1081,20 +1085,33 @@ def getNames(self): Please use diffpy.srfit.fitbase.FitRecipe.get_names instead.""" return self.get_names() - def getBounds(self): + def get_bounds_pairs(self): """Get the bounds on variables in a list. - Returns a list of (lb, ub) pairs, where lb is the lower bound - and ub is the upper bound. + Returns + ------- + bounds_pair_list : list of tuple of float + A list of ``(lower, upper)`` bounds on the variables, in the same + order as ``get_names`` and ``get_values``. """ return [v.bounds for v in self._parameters.values() if self.is_free(v)] + @deprecated(getBounds_dep_msg) + def getBounds(self): + """This function has been deprecated and will be removed in version + 4.0.0. + + Please use diffpy.srfit.fitbase.FitRecipe.get_bounds_pairs + instead. + """ + return self.get_bounds_pairs() + def getBounds2(self): """Get the bounds on variables in two lists. Returns lower- and upper-bound lists of variable bounds. """ - bounds = self.getBounds() + bounds = self.get_bounds_pairs() lb = array([b[0] for b in bounds]) ub = array([b[1] for b in bounds]) return lb, ub diff --git a/src/diffpy/srfit/fitbase/parameter.py b/src/diffpy/srfit/fitbase/parameter.py index 90691e55..067ab8ae 100644 --- a/src/diffpy/srfit/fitbase/parameter.py +++ b/src/diffpy/srfit/fitbase/parameter.py @@ -55,7 +55,7 @@ class Parameter(_parameter_interface, Argument, Validatable): bounds A 2-list defining the bounds on the Parameter. This can be used by some optimizers when the Parameter is varied. See - FitRecipe.getBounds and FitRecipe.boundsToRestraints. + FitRecipe.get_bounds_pairs and FitRecipe.boundsToRestraints. """ def __init__(self, name, value=None, const=False): @@ -238,7 +238,7 @@ def bounds(self): """List of lower and upper bounds of the proxied Parameter. This can be used by some optimizers when the Parameter is - varied. See FitRecipe.getBounds and + varied. See FitRecipe.get_bounds_pairs and FitRecipe.boundsToRestraints. """ return self.par.bounds From 71b8b4f90ac440e9fc2490952160a14ecf7cc687 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Sun, 22 Feb 2026 15:44:53 -0500 Subject: [PATCH 06/13] getBounds2 deprecation --- src/diffpy/srfit/fitbase/fitrecipe.py | 36 +++++++++++++++++++++------ 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 70050983..3bc26e2c 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -115,6 +115,10 @@ base, "getBounds", "get_bounds_pairs", removal_version ) +getBounds2_dep_msg = build_deprecation_message( + base, "getBounds2", "get_bounds_array", removal_version +) + class FitRecipe(_fitrecipe_interface, RecipeOrganizer): """FitRecipe class. @@ -178,7 +182,7 @@ class FitRecipe(_fitrecipe_interface, RecipeOrganizer): bounds Bounds on parameters (read only). See get_bounds_pairs. bounds2 - Bounds on parameters (read only). See getBounds2. + Bounds on parameters (read only). See get_bounds_array. """ fixednames = property( @@ -200,7 +204,7 @@ class FitRecipe(_fitrecipe_interface, RecipeOrganizer): doc="values of the fixed refinable variables", ) bounds = property(lambda self: self.get_bounds_pairs()) - bounds2 = property(lambda self: self.getBounds2()) + bounds2 = property(lambda self: self.get_bounds_array()) def __init__(self, name="fit"): """Initialization.""" @@ -1106,15 +1110,31 @@ def getBounds(self): """ return self.get_bounds_pairs() - def getBounds2(self): - """Get the bounds on variables in two lists. + def get_bounds_array(self): + """Get the bounds on variables in two numpy arrays. - Returns lower- and upper-bound lists of variable bounds. + Returns + ------- + lower_bounds : numpy.ndarray + A numpy array of lower bounds on the variables, in the same order + as ``get_names`` and ``get_values``. + upper_bounds : numpy.ndarray + A numpy array of upper bounds on the variables, in the same order + as ``get_names`` and ``get_values``. """ bounds = self.get_bounds_pairs() - lb = array([b[0] for b in bounds]) - ub = array([b[1] for b in bounds]) - return lb, ub + lower_bounds = array([b[0] for b in bounds]) + upper_bounds = array([b[1] for b in bounds]) + return lower_bounds, upper_bounds + + @deprecated(getBounds2_dep_msg) + def getBounds2(self): + """This function has been deprecated and will be removed in version + 4.0.0. + + Please use diffpy.srfit.fitbase.FitRecipe.get_bounds_array instead. + """ + return self.get_bounds_array() def set_plot_defaults(self, **kwargs): """Set default plotting options for all future plots. From 2985fbde3c82a0097bb8ff58dde4e769a872c6ed Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Sun, 22 Feb 2026 16:02:25 -0500 Subject: [PATCH 07/13] add test for boundsToRestraints --- tests/test_fitrecipe.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/test_fitrecipe.py b/tests/test_fitrecipe.py index ae466c96..b7fbe0d3 100644 --- a/tests/test_fitrecipe.py +++ b/tests/test_fitrecipe.py @@ -297,6 +297,40 @@ def testResidual(self): # ---------------------------------------------------------------------------- +def test_boundsToRestraints(): + recipe = FitRecipe("recipe") + + # create a bounded variable + recipe.create_new_variable("var1", 1) + recipe.var1.bounds = (-1, 1) + + # apply restraints from bounds + recipe.boundsToRestraints(sig=2, scaled=True) + restraints = list(recipe._restraints) + assert len(restraints) == 1 + r = restraints[0] + assert r.lb == -1 + assert r.ub == 1 + assert r.sig == 2 + assert r.scaled is True + + +def test_convert_bounds_to_restraints(): + recipe = FitRecipe("recipe") + # create a bounded variable + recipe.create_new_variable("var1", 1) + recipe.var1.bounds = (-1, 1) + # apply restraints from bounds + recipe.convert_bounds_to_restraints(sig=2, scaled=True) + restraints = list(recipe._restraints) + assert len(restraints) == 1 + r = restraints[0] + assert r.lb == -1 + assert r.ub == 1 + assert r.sig == 2 + assert r.scaled is True + + def testPrintFitHook(capturestdout): "check output from default PrintFitHook." recipe = FitRecipe("recipe") From 91a2ef4e28effcfae5ab7b0bb6e1665e3150d0f7 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Sun, 22 Feb 2026 16:02:50 -0500 Subject: [PATCH 08/13] boundsToRestraints deprecation --- src/diffpy/srfit/fitbase/fitrecipe.py | 17 ++++++++++++++++- src/diffpy/srfit/fitbase/parameter.py | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 3bc26e2c..d9ed9427 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -119,6 +119,10 @@ base, "getBounds2", "get_bounds_array", removal_version ) +boundsToRestraints_dep_msg = build_deprecation_message( + base, "boundsToRestraints", "convert_bounds_to_restraints", removal_version +) + class FitRecipe(_fitrecipe_interface, RecipeOrganizer): """FitRecipe class. @@ -1420,7 +1424,7 @@ def plot_recipe(self, ax=None, return_fig=False, **kwargs): else: return figures, axes_list - def boundsToRestraints(self, sig=1, scaled=False): + def convert_bounds_to_restraints(self, sig=1, scaled=False): """Turn all bounded parameters into restraints. The bounds become limits on the restraint. @@ -1442,6 +1446,17 @@ def boundsToRestraints(self, sig=1, scaled=False): ) return + @deprecated(boundsToRestraints_dep_msg) + def boundsToRestraints(self, sig=1, scaled=False): + """This function has been deprecated and will be removed in version + 4.0.0. + + Please use diffpy.srfit.fitbase.FitRecipe.convert_bounds_to_restraints + instead. + """ + self.convert_bounds_to_restraints(sig, scaled) + return + def _apply_values(self, p): """Apply variable values to the variables.""" if len(p) == 0: diff --git a/src/diffpy/srfit/fitbase/parameter.py b/src/diffpy/srfit/fitbase/parameter.py index 067ab8ae..d7887f7d 100644 --- a/src/diffpy/srfit/fitbase/parameter.py +++ b/src/diffpy/srfit/fitbase/parameter.py @@ -55,7 +55,7 @@ class Parameter(_parameter_interface, Argument, Validatable): bounds A 2-list defining the bounds on the Parameter. This can be used by some optimizers when the Parameter is varied. See - FitRecipe.get_bounds_pairs and FitRecipe.boundsToRestraints. + FitRecipe.get_bounds_pairs and FitRecipe.convert_bounds_to_restraints. """ def __init__(self, name, value=None, const=False): @@ -239,7 +239,7 @@ def bounds(self): This can be used by some optimizers when the Parameter is varied. See FitRecipe.get_bounds_pairs and - FitRecipe.boundsToRestraints. + FitRecipe.convert_bounds_to_restraints. """ return self.par.bounds From 346d1b2561368ad75a8e715a270bd14f42c804dd Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Sun, 22 Feb 2026 16:06:57 -0500 Subject: [PATCH 09/13] make bounds to restraints docstring better --- src/diffpy/srfit/fitbase/fitrecipe.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index d9ed9427..c28acc3e 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -1429,13 +1429,18 @@ def convert_bounds_to_restraints(self, sig=1, scaled=False): The bounds become limits on the restraint. - Attributes + Parameters ---------- - sig - The uncertainty on the bounds (scalar or iterable, - default 1). - scaled - Scale the restraints, see restrain. + sig : float or iterable of float, optional + The number of standard deviations associated with each bound. + Smaller values produce stronger restraints. If a scalar is given, + the same value is applied to all parameters. If an iterable is + provided, it must match the number of parameters. Default is 1. + + scaled : bool, optional + If True, scale each restraint by the magnitude of the corresponding + parameter, consistent with the behavior of :meth:`restrain`. + Default is False. """ pars = self._parameters.values() if not hasattr(sig, "__iter__"): From 64640a5b4f468e536e5af7b46974986de5b2aaea Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Sun, 22 Feb 2026 16:10:40 -0500 Subject: [PATCH 10/13] news --- news/fitrecipe2-dep.rst | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 news/fitrecipe2-dep.rst diff --git a/news/fitrecipe2-dep.rst b/news/fitrecipe2-dep.rst new file mode 100644 index 00000000..8ce1d4aa --- /dev/null +++ b/news/fitrecipe2-dep.rst @@ -0,0 +1,33 @@ +**Added:** + +* Added ``convert_bounds_to_restraints`` method to ``FitRecipe``. +* Added ``get_bounds_pairs`` method to ``FitRecipe``. +* Added ``get_bounds_array`` method to ``FitRecipe``. +* Added ``get_names`` method to ``FitRecipe``. +* Added ``get_values`` method to ``FitRecipe``. +* Added ``is_free`` method to ``FitRecipe``. + +**Changed:** + +* + +**Deprecated:** + +* Deprecated ``boundsToRestraints`` method for removal in 4.0.0. +* Deprecated ``getBounds`` method for removal in 4.0.0. +* Deprecated ``getBounds2`` method for removal in 4.0.0. +* Deprecated ``getNames`` method for removal in 4.0.0. +* Deprecated ``getValues`` method for removal in 4.0.0. +* Deprecated ``isFree`` method for removal in 4.0.0. + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From a840d5b60d325c56dcb564c0c986f6e255c067fd Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Sun, 22 Feb 2026 16:16:17 -0500 Subject: [PATCH 11/13] news 2 --- news/fitrecipe2-dep.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/news/fitrecipe2-dep.rst b/news/fitrecipe2-dep.rst index 8ce1d4aa..0b7d9e3a 100644 --- a/news/fitrecipe2-dep.rst +++ b/news/fitrecipe2-dep.rst @@ -3,8 +3,8 @@ * Added ``convert_bounds_to_restraints`` method to ``FitRecipe``. * Added ``get_bounds_pairs`` method to ``FitRecipe``. * Added ``get_bounds_array`` method to ``FitRecipe``. -* Added ``get_names`` method to ``FitRecipe``. -* Added ``get_values`` method to ``FitRecipe``. +* Added ``get_names`` method to ``FitRecipe`` and ``RecipeContainer``. +* Added ``get_values`` method to ``FitRecipe`` and ``RecipeContainer``. * Added ``is_free`` method to ``FitRecipe``. **Changed:** From deb7303e08f5f80d8231988207349e8a898984c5 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Sun, 22 Feb 2026 16:18:37 -0500 Subject: [PATCH 12/13] make new test cleaner --- tests/test_fitrecipe.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/test_fitrecipe.py b/tests/test_fitrecipe.py index b7fbe0d3..ec3f4802 100644 --- a/tests/test_fitrecipe.py +++ b/tests/test_fitrecipe.py @@ -302,16 +302,22 @@ def test_boundsToRestraints(): # create a bounded variable recipe.create_new_variable("var1", 1) - recipe.var1.bounds = (-1, 1) + expected_lower_bound = -1 + expected_upper_bound = 1 + expected_sigma = 2 + recipe.var1.bounds = (-expected_lower_bound, expected_upper_bound) # apply restraints from bounds - recipe.boundsToRestraints(sig=2, scaled=True) + recipe.boundsToRestraints(sig=expected_sigma, scaled=True) restraints = list(recipe._restraints) assert len(restraints) == 1 r = restraints[0] - assert r.lb == -1 - assert r.ub == 1 - assert r.sig == 2 + actual_lower_bound = r.lb + actual_upper_bound = r.ub + actual_sigma = r.sig + assert actual_lower_bound == expected_lower_bound + assert actual_upper_bound == expected_upper_bound + assert actual_sigma == expected_sigma assert r.scaled is True From 526034db41b8ca82246333b7a5832d253c31c17e Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Mon, 23 Feb 2026 09:04:15 -0500 Subject: [PATCH 13/13] remove minus sign typo causing tests to fail --- tests/test_fitrecipe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fitrecipe.py b/tests/test_fitrecipe.py index ec3f4802..48e0bf15 100644 --- a/tests/test_fitrecipe.py +++ b/tests/test_fitrecipe.py @@ -305,7 +305,7 @@ def test_boundsToRestraints(): expected_lower_bound = -1 expected_upper_bound = 1 expected_sigma = 2 - recipe.var1.bounds = (-expected_lower_bound, expected_upper_bound) + recipe.var1.bounds = (expected_lower_bound, expected_upper_bound) # apply restraints from bounds recipe.boundsToRestraints(sig=expected_sigma, scaled=True)