From 4f247d600db007c84caad3bef09ed16cbf93abb1 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:14:59 -0500 Subject: [PATCH 01/59] _update_configuration --- docs/source/extending.rst | 4 ++-- src/diffpy/srfit/fitbase/configurable.py | 4 ++-- src/diffpy/srfit/fitbase/fitrecipe.py | 6 +++--- src/diffpy/srfit/fitbase/recipeorganizer.py | 8 ++++---- src/diffpy/srfit/structure/srrealparset.py | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/source/extending.rst b/docs/source/extending.rst index 464cd16c..6e3563de 100644 --- a/docs/source/extending.rst +++ b/docs/source/extending.rst @@ -236,9 +236,9 @@ structures. The restraint is applied with the ``restrainBVS`` method. The purpose of the method is to create the custom ``Restraint`` object, configure it and store it. Note that the optional `sig` and `scaled` flag are passed as part of this method. Both ``_restraints`` and -``_updateConfiguration`` come from ``ParameterSet``, from which +``_update_configuration`` come from ``ParameterSet``, from which ``SrRealParSet`` is derived. The ``_restraints`` attribute is a set of -``Restraints`` on the object. The ``_updateConfiguration`` method makes any +``Restraints`` on the object. The ``_update_configuration`` method makes any object containing the ``SrRealParSet`` aware of the configuration change. This gets propagated to the top-level ``FitRecipe``, if there is one. The restraint object is returned by the method so that it may be later removed. diff --git a/src/diffpy/srfit/fitbase/configurable.py b/src/diffpy/srfit/fitbase/configurable.py index a06c62ba..81b8de4a 100644 --- a/src/diffpy/srfit/fitbase/configurable.py +++ b/src/diffpy/srfit/fitbase/configurable.py @@ -37,10 +37,10 @@ def __init__(self): self._configobjs = set() return - def _updateConfiguration(self): + def _update_configuration(self): """Notify Configurables in hierarchy of configuration change.""" for obj in self._configobjs: - obj._updateConfiguration() + obj._update_configuration() return def _storeConfigurable(self, obj): diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 229d2447..3cd4ceac 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -173,7 +173,7 @@ def pushFitHook(self, fithook, index=None): index = len(self.fithooks) self.fithooks.insert(index, fithook) # Make sure the added FitHook gets its reset method called. - self._updateConfiguration() + self._update_configuration() return def popFitHook(self, fithook=None, index=-1): @@ -781,7 +781,7 @@ def unconstrain(self, *pars): if update: # Our configuration changed - self._updateConfiguration() + self._update_configuration() return @@ -902,7 +902,7 @@ def _applyValues(self, p): var.setValue(pval) return - def _updateConfiguration(self): + def _update_configuration(self): """Notify RecipeContainers in hierarchy of configuration change.""" self._ready = False return diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index a76593d5..ab7cbfff 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -733,7 +733,7 @@ def constrain(self, par, con, ns={}): self._constraints[par] = con # Our configuration changed - self._updateConfiguration() + self._update_configuration() return @@ -780,7 +780,7 @@ def unconstrain(self, *pars): if update: # Our configuration changed - self._updateConfiguration() + self._update_configuration() else: @@ -881,7 +881,7 @@ def addRestraint(self, res): """ self._restraints.add(res) # Our configuration changed. Notify observers. - self._updateConfiguration() + self._update_configuration() return def unrestrain(self, *ress): @@ -902,7 +902,7 @@ def unrestrain(self, *ress): if update: # Our configuration changed - self._updateConfiguration() + self._update_configuration() return diff --git a/src/diffpy/srfit/structure/srrealparset.py b/src/diffpy/srfit/structure/srrealparset.py index 4d7ddee3..cb5f95fe 100644 --- a/src/diffpy/srfit/structure/srrealparset.py +++ b/src/diffpy/srfit/structure/srrealparset.py @@ -69,7 +69,7 @@ def restrainBVS(self, sig=1, scaled=False): # Add it to the _restraints set self._restraints.add(res) # Our configuration changed. Notify observers. - self._updateConfiguration() + self._update_configuration() # Return the Restraint object return res From 3ea20f0f915fc0d24751cd880a369c3d2617788a Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:17:09 -0500 Subject: [PATCH 02/59] _store_configurable --- src/diffpy/srfit/fitbase/configurable.py | 2 +- src/diffpy/srfit/fitbase/recipeorganizer.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/fitbase/configurable.py b/src/diffpy/srfit/fitbase/configurable.py index 81b8de4a..8fb275bc 100644 --- a/src/diffpy/srfit/fitbase/configurable.py +++ b/src/diffpy/srfit/fitbase/configurable.py @@ -43,7 +43,7 @@ def _update_configuration(self): obj._update_configuration() return - def _storeConfigurable(self, obj): + def _store_configurable(self, obj): """Store a Configurable. The passed obj is only stored if it is a a Configurable, diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index ab7cbfff..808d1184 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -289,7 +289,7 @@ def _addObject(self, obj, d, check=True): obj.addObserver(self._flush) # Store this as a configurable object - self._storeConfigurable(obj) + self._store_configurable(obj) return def _removeObject(self, obj, d): From e664263e0a50705f94a16e550d28f9101df17b09 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:20:42 -0500 Subject: [PATCH 03/59] __verify_profiles and __collect_constraints_and_restraints --- src/diffpy/srfit/fitbase/fitrecipe.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 3cd4ceac..ddc7443f 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -351,13 +351,13 @@ def _prepare(self): fithook.reset(self) # Check Profiles - self.__verifyProfiles() + self.__verify_profiles() # Check parameters - self.__verifyParameters() + self.__verify_parameters() # Update constraints and restraints. - self.__collectConstraintsAndRestraints() + self.__collect_constraints_and_restraints() # We do this here so that the calculations that take place during the # validation use the most current values of the parameters. In most @@ -372,7 +372,7 @@ def _prepare(self): return - def __verifyProfiles(self): + def __verify_profiles(self): """Verify that each FitContribution has a Profile.""" # Check for profile values for con in self._contributions.values(): @@ -389,7 +389,7 @@ def __verifyProfiles(self): raise AttributeError(m) return - def __verifyParameters(self): + def __verify_parameters(self): """Verify that all Parameters have values.""" # Get all parameters with a value of None @@ -421,7 +421,7 @@ def __verifyParameters(self): return - def __collectConstraintsAndRestraints(self): + def __collect_constraints_and_restraints(self): """Collect the Constraints and Restraints from subobjects.""" from functools import cmp_to_key from itertools import chain From b4d1142c5cf291fb21e7f7d93ac6b5144e8947f3 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:22:40 -0500 Subject: [PATCH 04/59] _new_parameter --- docs/examples/gaussiangenerator.py | 12 ++++++------ src/diffpy/srfit/fitbase/fitrecipe.py | 8 ++++---- src/diffpy/srfit/fitbase/parameterset.py | 2 +- src/diffpy/srfit/fitbase/recipeorganizer.py | 6 +++--- src/diffpy/srfit/interface/interface.py | 6 +++--- src/diffpy/srfit/sas/prcalculator.py | 8 ++++---- tests/test_recipeorganizer.py | 20 ++++++++++---------- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/docs/examples/gaussiangenerator.py b/docs/examples/gaussiangenerator.py index fedff5a5..ff65fb96 100644 --- a/docs/examples/gaussiangenerator.py +++ b/docs/examples/gaussiangenerator.py @@ -85,13 +85,13 @@ def __init__(self, name): # This initializes various parts of the generator ProfileGenerator.__init__(self, name) - # Here we create new Parameters using the '_newParameter' method of + # Here we create new Parameters using the '_new_parameter' method of # ProfileGenerator. The signature is - # _newParameter(name, value). + # _new_parameter(name, value). # See the API for full details. - self._newParameter("A", 1.0) - self._newParameter("x0", 0.0) - self._newParameter("sigma", 1.0) + self._new_parameter("A", 1.0) + self._new_parameter("x0", 0.0) + self._new_parameter("sigma", 1.0) return def __call__(self, x): @@ -101,7 +101,7 @@ def __call__(self, x): variable, x. We will define it as we did in gaussianrecipe.py. """ # First we must get the values of the Parameters. Since we used - # _newParameter to create them, the Parameters are accessible as + # _new_parameter to create them, the Parameters are accessible as # attributes by name. A = self.A.value x0 = self.x0.value diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index ddc7443f..c767b1e8 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -605,7 +605,7 @@ def newVar(self, name, value=None, fixed=False, tag=None, tags=[]): Returns the new variable (Parameter instance). """ # This will fix the Parameter - var = self._newParameter(name, value) + var = self._new_parameter(name, value) # We may explicitly free it if not fixed: @@ -618,12 +618,12 @@ def newVar(self, name, value=None, fixed=False, tag=None, tags=[]): return var - def _newParameter(self, name, value, check=True): + def _new_parameter(self, name, value, check=True): """Overloaded to tag variables. - See RecipeOrganizer._newParameter + See RecipeOrganizer._new_parameter """ - par = RecipeOrganizer._newParameter(self, name, value, check) + par = RecipeOrganizer._new_parameter(self, name, value, check) # tag this self._tagmanager.tag(par, par.name) self._tagmanager.tag(par, "all") diff --git a/src/diffpy/srfit/fitbase/parameterset.py b/src/diffpy/srfit/fitbase/parameterset.py index 53edb035..53f9fc2e 100644 --- a/src/diffpy/srfit/fitbase/parameterset.py +++ b/src/diffpy/srfit/fitbase/parameterset.py @@ -84,7 +84,7 @@ def __init__(self, name): # Alias Parameter accessors. addParameter = RecipeOrganizer._addParameter - newParameter = RecipeOrganizer._newParameter + newParameter = RecipeOrganizer._new_parameter removeParameter = RecipeOrganizer._removeParameter def addParameterSet(self, parset): diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index 808d1184..d395e6bc 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -420,7 +420,7 @@ def __init__(self, name): # Parameter management - def _newParameter(self, name, value, check=True): + def _new_parameter(self, name, value, check=True): """Add a new Parameter to the container. This creates a new Parameter and adds it to the container using @@ -501,7 +501,7 @@ def registerCalculator(self, f, argnames=None): for pname in argnames: if pname not in self._eqfactory.builders: - par = self._newParameter(pname, 0) + par = self._new_parameter(pname, 0) else: par = self.get(pname) f.addLiteral(par) @@ -598,7 +598,7 @@ def registerFunction(self, f, name=None, argnames=None): # Make missing Parameters for pname in argnames: if pname not in self._eqfactory.builders: - self._newParameter(pname, 0) + self._new_parameter(pname, 0) # Initialize and register from diffpy.srfit.fitbase.calculator import Calculator diff --git a/src/diffpy/srfit/interface/interface.py b/src/diffpy/srfit/interface/interface.py index a0b7a21a..b547173e 100644 --- a/src/diffpy/srfit/interface/interface.py +++ b/src/diffpy/srfit/interface/interface.py @@ -81,17 +81,17 @@ def __imod__(self, args): return self def __iadd__(self, args): - """_newParameter or _addParameter with += + """_new_parameter or _addParameter with += Think of "+" as addition of a Parameter. This accepts arguments for a single function call. """ - # Want to detect _addParameter or _newParameter + # Want to detect _addParameter or _new_parameter def f(*args): if isinstance(args[0], six.string_types): - self._newParameter(*args) + self._new_parameter(*args) else: self._addParameter(*args) return diff --git a/src/diffpy/srfit/sas/prcalculator.py b/src/diffpy/srfit/sas/prcalculator.py index 74fd811a..17c63de6 100644 --- a/src/diffpy/srfit/sas/prcalculator.py +++ b/src/diffpy/srfit/sas/prcalculator.py @@ -82,10 +82,10 @@ def __init__(self, name): self._invertor = Invertor() - self._newParameter("scale", 1) - self._newParameter("q", None) - self._newParameter("iq", None) - self._newParameter("diq", None) + self._new_parameter("scale", 1) + self._new_parameter("q", None) + self._new_parameter("iq", None) + self._new_parameter("diq", None) return def __call__(self, r): diff --git a/tests/test_recipeorganizer.py b/tests/test_recipeorganizer.py index 88909b91..847acded 100644 --- a/tests/test_recipeorganizer.py +++ b/tests/test_recipeorganizer.py @@ -189,10 +189,10 @@ def testNewParameter(self): m._addParameter(p1) # Test duplication of Parameters - self.assertRaises(ValueError, m._newParameter, "p1", 0) + self.assertRaises(ValueError, m._new_parameter, "p1", 0) # Add a new Parameter - p2 = m._newParameter("p2", 0) + p2 = m._new_parameter("p2", 0) self.assertTrue(p2 is m.p2) return @@ -262,8 +262,8 @@ def testRemoveParameter(self): def testConstrain(self): """Test the constrain method.""" - p1 = self.m._newParameter("p1", 1) - p2 = self.m._newParameter("p2", 2) + p1 = self.m._new_parameter("p1", 1) + p2 = self.m._new_parameter("p2", 2) p3 = Parameter("p3", 3) self.assertFalse(p1.constrained) @@ -483,7 +483,7 @@ def testRegisterStringFunction(self): self.assertTrue(p in self.m._parameters.values()) # Add a parameter - self.m._newParameter("y", 3.0) + self.m._new_parameter("y", 3.0) # Make sure that x and y are in the organizer self.assertEqual(0, self.m.x.getValue()) @@ -512,7 +512,7 @@ def testRegisterStringFunction(self): def test_releaseOldEquations(self): """Verify EquationFactory does not hold temporary equations.""" - self.m._newParameter("x", 12) + self.m._new_parameter("x", 12) self.assertEqual(36, self.m.evaluateEquation("3 * x")) self.assertEqual(0, len(self.m._eqfactory.equations)) return @@ -530,15 +530,15 @@ def capture_show(*args, **kwargs): return rv assert "" == capture_show() - organizer._newParameter("x", 1) - organizer._newParameter("y", 2) + organizer._new_parameter("x", 1) + organizer._new_parameter("y", 2) out1 = capture_show() lines1 = out1.strip().split("\n") assert 4 == len(lines1) assert "Parameters" in lines1 assert "Constraints" not in lines1 assert "Restraints" not in lines1 - organizer._newParameter("z", 7) + organizer._new_parameter("z", 7) organizer.constrain("y", "3 * z") out2 = capture_show() lines2 = out2.strip().split("\n") @@ -560,7 +560,7 @@ def capture_show(*args, **kwargs): assert out3 == out5 # check output with another level of hierarchy organizer._addObject(RecipeOrganizer("foo"), organizer._containers) - organizer.foo._newParameter("bar", 13) + organizer.foo._new_parameter("bar", 13) out6 = capture_show() assert "foo.bar" in out6 # filter out foo.bar From faf2edbd6afac20858d7cba73a2498bcb58c8058 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:23:10 -0500 Subject: [PATCH 05/59] __get_var_and_check --- src/diffpy/srfit/fitbase/fitrecipe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index c767b1e8..1af7cc94 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -630,7 +630,7 @@ def _new_parameter(self, name, value, check=True): self.fix(par.name) return par - def __getVarAndCheck(self, var): + def __get_var_and_check(self, var): """Get the actual variable from var. Attributes From bed70e78d7b6ab678506878f56345044b1df0904 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:23:50 -0500 Subject: [PATCH 06/59] __get_vars_from_args --- src/diffpy/srfit/fitbase/fitrecipe.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 1af7cc94..1f744a88 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -649,7 +649,7 @@ def __get_var_and_check(self, var): return var - def __getVarsFromArgs(self, *args, **kw): + def __get_vars_from_args(self, *args, **kw): """Get a list of variables from passed arguments. This method accepts string or variable arguments. An argument of @@ -705,7 +705,7 @@ def fix(self, *args, **kw): passed, or if a tag is passed in a keyword. """ # Check the inputs and get the variables from them - varargs = self.__getVarsFromArgs(*args, **kw) + varargs = self.__get_vars_from_args(*args, **kw) # Fix all of these for var in varargs: @@ -731,7 +731,7 @@ def free(self, *args, **kw): passed, or if a tag is passed in a keyword. """ # Check the inputs and get the variables from them - varargs = self.__getVarsFromArgs(*args, **kw) + varargs = self.__get_vars_from_args(*args, **kw) # Free all of these for var in varargs: From 002b4b36355e7524108c0502c91b4af8072dee13 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:24:40 -0500 Subject: [PATCH 07/59] _apply_values --- src/diffpy/srfit/fitbase/fitrecipe.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 1f744a88..9c7b887d 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -279,7 +279,7 @@ def residual(self, p=[]): fithook.precall(self) # Update the variable parameters. - self._applyValues(p) + self._apply_values(p) # Update the constraints. These are ordered such that the list only # needs to be cycled once. @@ -893,7 +893,7 @@ def boundsToRestraints(self, sig=1, scaled=False): ) return - def _applyValues(self, p): + def _apply_values(self, p): """Apply variable values to the variables.""" if len(p) == 0: return From 820a6ffe1107b09104da4c25de0f8a5c12488473 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:25:28 -0500 Subject: [PATCH 08/59] _calculate_covariance --- src/diffpy/srfit/fitbase/fitresults.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitresults.py b/src/diffpy/srfit/fitbase/fitresults.py index 108c2fcf..b810526e 100644 --- a/src/diffpy/srfit/fitbase/fitresults.py +++ b/src/diffpy/srfit/fitbase/fitresults.py @@ -165,7 +165,7 @@ def update(self): if self.varnames: # Calculate the covariance - self._calculateCovariance() + self._calculate_covariance() # Get the variable uncertainties self.varunc = [ @@ -193,7 +193,7 @@ def update(self): return - def _calculateCovariance(self): + def _calculate_covariance(self): """Calculate the covariance matrix. This is called by update. This code borrowed from PARK. It finds the pseudo-inverse of the From 0a8ec034ddfc34b5d78fb9f22cc5a4d72a422390 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:25:56 -0500 Subject: [PATCH 09/59] _calculate_jacobian --- src/diffpy/srfit/fitbase/fitresults.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitresults.py b/src/diffpy/srfit/fitbase/fitresults.py index b810526e..961c39d8 100644 --- a/src/diffpy/srfit/fitbase/fitresults.py +++ b/src/diffpy/srfit/fitbase/fitresults.py @@ -200,7 +200,7 @@ def _calculate_covariance(self): Jacobian using the singular value decomposition. """ try: - J = self._calculateJacobian() + J = self._calculate_jacobian() u, s, vh = numpy.linalg.svd(J, 0) self.cov = numpy.dot(vh.T.conj() / s**2, vh) except numpy.linalg.LinAlgError: @@ -209,7 +209,7 @@ def _calculate_covariance(self): self.cov = numpy.zeros((lvarvals, lvarvals), dtype=float) return - def _calculateJacobian(self): + def _calculate_jacobian(self): """Calculate the Jacobian for the fitting. Adapted from PARK. Returns the derivative wrt the fit variables From 534c100b5802e7be981dc607f2349de2145c6ef4 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:26:25 -0500 Subject: [PATCH 10/59] _calculate_metrics --- src/diffpy/srfit/fitbase/fitresults.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitresults.py b/src/diffpy/srfit/fitbase/fitresults.py index 961c39d8..e8219949 100644 --- a/src/diffpy/srfit/fitbase/fitresults.py +++ b/src/diffpy/srfit/fitbase/fitresults.py @@ -185,7 +185,7 @@ def update(self): # Calculate the metrics res = recipe.residual() self.residual = numpy.dot(res, res) - self._calculateMetrics() + self._calculate_metrics() # Calculate the restraints penalty w = self.chi2 / len(res) @@ -276,7 +276,7 @@ def _calculate_jacobian(self): jac = numpy.vstack(r).T return jac - def _calculateMetrics(self): + def _calculate_metrics(self): """Calculate chi2, cumchi2, rchi2, rw and cumrw for the recipe.""" cumchi2 = numpy.array([], dtype=float) # total weighed denominator for the ratio in the Rw formula @@ -657,7 +657,7 @@ def _init(self, con, weight, fitres): self.ycalc = numpy.array(con.profile.ycalc) # The other metrics - self._calculateMetrics() + self._calculate_metrics() # Find the parameters for i, constraint in enumerate(recipe._oconstraints): @@ -671,7 +671,7 @@ def _init(self, con, weight, fitres): return # FIXME: factor rw, chi2, cumrw, cumchi2 to separate functions. - def _calculateMetrics(self): + def _calculate_metrics(self): """Calculate chi2 and Rw of the recipe.""" # We take absolute values in case the signal is complex num = numpy.abs(self.y - self.ycalc) From ba6202b5b12bba114ddc66b0a2eee4cb4964ef38 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:26:59 -0500 Subject: [PATCH 11/59] _calculate_constraint_uncertainties --- src/diffpy/srfit/fitbase/fitresults.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitresults.py b/src/diffpy/srfit/fitbase/fitresults.py index e8219949..85b3bbfc 100644 --- a/src/diffpy/srfit/fitbase/fitresults.py +++ b/src/diffpy/srfit/fitbase/fitresults.py @@ -173,7 +173,7 @@ def update(self): ] # Get the constraint uncertainties - self._calculateConstraintUncertainties() + self._calculate_constraint_uncertainties() # Store the fitting arrays and metrics for each FitContribution. self.conresults = OrderedDict() @@ -303,7 +303,7 @@ def _calculate_metrics(self): self.cumrw = cumrw return - def _calculateConstraintUncertainties(self): + def _calculate_constraint_uncertainties(self): """Calculate the uncertainty on the constrained parameters.""" vu = self.varunc From 8a1b4ead514f650b4e99771d5953868c975559ef Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:28:57 -0500 Subject: [PATCH 12/59] _iter_managed --- src/diffpy/srfit/fitbase/recipeorganizer.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index d395e6bc..2fa58845 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -112,7 +112,7 @@ def _manage(self, d): self.__managed.append(d) return - def _iterManaged(self): + def _iter_managed(self): """Get iterator over managed objects.""" return chain(*(d.values() for d in self.__managed)) @@ -326,7 +326,7 @@ def _locateManagedObject(self, obj): if obj is self: return loc - for m in self._iterManaged(): + for m in self._iter_managed(): # Check locally for the object if m is obj: @@ -359,7 +359,7 @@ def _validate(self): Raises AttributeError if validation fails. """ - iterable = chain(self.__iter__(), self._iterManaged()) + iterable = chain(self.__iter__(), self._iter_managed()) self._validateOthers(iterable) return @@ -817,7 +817,7 @@ def clearConstraints(self, recurse=False): self.unconstrain(*self._constraints) if recurse: - for m in filter(_has_clear_constraints, self._iterManaged()): + for m in filter(_has_clear_constraints, self._iter_managed()): m.clearConstraints(recurse) return @@ -917,7 +917,7 @@ def clearRestraints(self, recurse=False): """ self.unrestrain(*self._restraints) if recurse: - for msg in filter(_has_clear_restraints, self._iterManaged()): + for msg in filter(_has_clear_restraints, self._iter_managed()): msg.clearRestraints(recurse) return @@ -925,7 +925,7 @@ def _getConstraints(self, recurse=True): """Get the constrained Parameters for this and managed sub-objects.""" constraints = {} if recurse: - for m in filter(_has_get_constraints, self._iterManaged()): + for m in filter(_has_get_constraints, self._iter_managed()): constraints.update(m._getConstraints(recurse)) constraints.update(self._constraints) @@ -939,7 +939,7 @@ def _getRestraints(self, recurse=True): """ restraints = set(self._restraints) if recurse: - for m in filter(_has_get_restraints, self._iterManaged()): + for m in filter(_has_get_restraints, self._iter_managed()): restraints.update(m._getRestraints(recurse)) return restraints @@ -984,7 +984,7 @@ def _formatManaged(self, prefix=""): for n, p in self._parameters.items() ) # Recurse into managed objects. - for obj in self._iterManaged(): + for obj in self._iter_managed(): if hasattr(obj, "_formatManaged"): oprefix = prefix + obj.name + "." tlines = obj._formatManaged(prefix=oprefix) From e3d6773e3c215119d83b2ac2fc7ba9796e74e2f5 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:29:48 -0500 Subject: [PATCH 13/59] _add_object --- src/diffpy/srfit/fitbase/fitcontribution.py | 2 +- src/diffpy/srfit/fitbase/fitrecipe.py | 4 ++-- src/diffpy/srfit/fitbase/parameterset.py | 2 +- src/diffpy/srfit/fitbase/recipeorganizer.py | 6 +++--- src/diffpy/srfit/structure/sgconstraints.py | 2 +- tests/test_recipeorganizer.py | 20 ++++++++++---------- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitcontribution.py b/src/diffpy/srfit/fitbase/fitcontribution.py index b203cb22..80463a12 100644 --- a/src/diffpy/srfit/fitbase/fitcontribution.py +++ b/src/diffpy/srfit/fitbase/fitcontribution.py @@ -188,7 +188,7 @@ def addProfileGenerator(self, gen, name=None): # Register the generator with the equation factory and add it as a # managed object. self._eqfactory.registerOperator(name, gen) - self._addObject(gen, self._generators, True) + self._add_object(gen, self._generators, True) # If we have a profile, set the profile of the generator. if self.profile is not None: diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 9c7b887d..0e08616a 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -220,7 +220,7 @@ def addContribution(self, con, weight=1.0): Raises ValueError if the FitContribution has the same name as some other managed object. """ - self._addObject(con, self._contributions, True) + self._add_object(con, self._contributions, True) self._weights.append(weight) return @@ -243,7 +243,7 @@ def addParameterSet(self, parset): Raises ValueError if the ParameterSet has the same name as some other managed object. """ - self._addObject(parset, self._parsets, True) + self._add_object(parset, self._parsets, True) return def removeParameterSet(self, parset): diff --git a/src/diffpy/srfit/fitbase/parameterset.py b/src/diffpy/srfit/fitbase/parameterset.py index 53f9fc2e..d79da46f 100644 --- a/src/diffpy/srfit/fitbase/parameterset.py +++ b/src/diffpy/srfit/fitbase/parameterset.py @@ -100,7 +100,7 @@ def addParameterSet(self, parset): Raises ValueError if the ParameterSet has the same name as some other managed object. """ - self._addObject(parset, self._parsets, True) + self._add_object(parset, self._parsets, True) return def removeParameterSet(self, parset): diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index 2fa58845..db09152d 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -237,7 +237,7 @@ def getValues(self): """Get the values of managed parameters.""" return [p.value for p in self._parameters.values()] - def _addObject(self, obj, d, check=True): + def _add_object(self, obj, d, check=True): """Add an object to a managed dictionary. Attributes @@ -452,7 +452,7 @@ def _addParameter(self, par, check=True): """ # Store the Parameter - RecipeContainer._addObject(self, par, self._parameters, check) + RecipeContainer._add_object(self, par, self._parameters, check) # Register the Parameter self._eqfactory.registerArgument(par.name, par) @@ -492,7 +492,7 @@ def registerCalculator(self, f, argnames=None): extracted from the function. """ self._eqfactory.registerOperator(f.name, f) - self._addObject(f, self._calculators) + self._add_object(f, self._calculators) # Register arguments of the calculator if argnames is None: fncode = f.__call__.__func__.__code__ diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index ad3ba0eb..85f4b4f8 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -201,7 +201,7 @@ def addParameter(self, par, check=True): Raises ValueError if the Parameter has no name. """ # Store the Parameter - RecipeContainer._addObject(self, par, self._parameters, check) + RecipeContainer._add_object(self, par, self._parameters, check) return diff --git a/tests/test_recipeorganizer.py b/tests/test_recipeorganizer.py index 847acded..3bb69789 100644 --- a/tests/test_recipeorganizer.py +++ b/tests/test_recipeorganizer.py @@ -98,13 +98,13 @@ def testAccessors(self): """Test accessors.""" m1 = self.m p1 = Parameter("p1", 1) - m1._addObject(p1, m1._parameters) + m1._add_object(p1, m1._parameters) m2 = RecipeContainer("m2") p2 = Parameter("p2", 2) - m2._addObject(p2, m2._parameters) + m2._add_object(p2, m2._parameters) - m1._addObject(m2, m1._containers) + m1._add_object(m2, m1._containers) self.assertTrue(m1.m2 is m2) self.assertTrue(m1.p1 is p1) @@ -128,13 +128,13 @@ def testLocateManagedObject(self): """Test the locateManagedObject method.""" m1 = self.m p1 = Parameter("p1", 1) - m1._addObject(p1, m1._parameters) + m1._add_object(p1, m1._parameters) m2 = RecipeContainer("m2") p2 = Parameter("p2", 2) - m2._addObject(p2, m2._parameters) + m2._add_object(p2, m2._parameters) - m1._addObject(m2, m1._containers) + m1._add_object(m2, m1._containers) p3 = Parameter("p3", 3) @@ -220,7 +220,7 @@ def testAddParameter(self): # Try to insert a Parameter when a RecipeContainer with the same name # is already inside. c = RecipeContainer("test") - m._addObject(c, m._containers) + m._add_object(c, m._containers) p3 = Parameter("test", 0) self.assertRaises(ValueError, m._addParameter, p3) @@ -328,7 +328,7 @@ def testGetConstraints(self): m2 = RecipeOrganizer("m2") self.m._organizers = {} self.m._manage(self.m._organizers) - self.m._addObject(m2, self.m._organizers) + self.m._add_object(m2, self.m._organizers) p1 = Parameter("p1", 1) p2 = Parameter("p2", 2) @@ -355,7 +355,7 @@ def testGetRestraints(self): m2 = RecipeOrganizer("m2") self.m._organizers = {} self.m._manage(self.m._organizers) - self.m._addObject(m2, self.m._organizers) + self.m._add_object(m2, self.m._organizers) p1 = Parameter("p1", 1) p2 = Parameter("p2", 2) @@ -559,7 +559,7 @@ def capture_show(*args, **kwargs): out5 = capture_show(pattern="^") assert out3 == out5 # check output with another level of hierarchy - organizer._addObject(RecipeOrganizer("foo"), organizer._containers) + organizer._add_object(RecipeOrganizer("foo"), organizer._containers) organizer.foo._new_parameter("bar", 13) out6 = capture_show() assert "foo.bar" in out6 From d70790092f46f2b820f092393bbd91e4bed6c9c1 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:30:14 -0500 Subject: [PATCH 14/59] _remove_object --- src/diffpy/srfit/fitbase/fitrecipe.py | 2 +- src/diffpy/srfit/fitbase/parameterset.py | 2 +- src/diffpy/srfit/fitbase/recipeorganizer.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 0e08616a..91add7ac 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -251,7 +251,7 @@ def removeParameterSet(self, parset): Raises ValueError if parset is not managed by this object. """ - self._removeObject(parset, self._parsets) + self._remove_object(parset, self._parsets) return def residual(self, p=[]): diff --git a/src/diffpy/srfit/fitbase/parameterset.py b/src/diffpy/srfit/fitbase/parameterset.py index d79da46f..fc61dfea 100644 --- a/src/diffpy/srfit/fitbase/parameterset.py +++ b/src/diffpy/srfit/fitbase/parameterset.py @@ -108,7 +108,7 @@ def removeParameterSet(self, parset): Raises ValueError if parset is not managed by this object. """ - self._removeObject(parset, self._parsets) + self._remove_object(parset, self._parsets) return def setConst(self, const=True): diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index db09152d..be95d1ce 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -292,7 +292,7 @@ def _add_object(self, obj, d, check=True): self._store_configurable(obj) return - def _removeObject(self, obj, d): + def _remove_object(self, obj, d): """Remove an object from a managed dictionary. Raises ValueError if obj is not part of the dictionary. @@ -469,7 +469,7 @@ def _removeParameter(self, par): Raises ValueError if par is not part of the RecipeOrganizer. """ - self._removeObject(par, self._parameters) + self._remove_object(par, self._parameters) self._eqfactory.deRegisterBuilder(par.name) return From 0194888e99148387494ca014850ca0833ce7e6fd Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:30:46 -0500 Subject: [PATCH 15/59] _locate_managed_object --- src/diffpy/srfit/fitbase/fitrecipe.py | 2 +- src/diffpy/srfit/fitbase/fitresults.py | 4 ++-- src/diffpy/srfit/fitbase/recipeorganizer.py | 10 +++++----- tests/test_recipeorganizer.py | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 91add7ac..18fbee52 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -403,7 +403,7 @@ def __verify_parameters(self): # Get the bad names badnames = [] for par in badpars: - objlist = self._locateManagedObject(par) + objlist = self._locate_managed_object(par) names = [obj.name for obj in objlist] badnames.append(".".join(names)) diff --git a/src/diffpy/srfit/fitbase/fitresults.py b/src/diffpy/srfit/fitbase/fitresults.py index 85b3bbfc..1949526a 100644 --- a/src/diffpy/srfit/fitbase/fitresults.py +++ b/src/diffpy/srfit/fitbase/fitresults.py @@ -600,7 +600,7 @@ class ContributionResults(object): conlocs The location of the constrained parameters in the FitContribution (see the - RecipeContainer._locateManagedObject method). + RecipeContainer._locate_managed_object method). convals Values of the constrained parameters. conunc @@ -662,7 +662,7 @@ def _init(self, con, weight, fitres): # Find the parameters for i, constraint in enumerate(recipe._oconstraints): par = constraint.par - loc = con._locateManagedObject(par) + loc = con._locate_managed_object(par) if loc: self.conlocs.append(loc) self.convals.append(fitres.convals[i]) diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index be95d1ce..ec4cfcf7 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -50,7 +50,7 @@ class RecipeContainer(Observable, Configurable, Validatable): RecipeContainers are hierarchical organizations of Parameters and other RecipeContainers. This class provides attribute-access to these contained objects. Parameters and other RecipeContainers can be found within the - hierarchy with the _locateManagedObject method. + hierarchy with the _locate_managed_object method. A RecipeContainer can manage dictionaries for that store various objects. These dictionaries can be added to the RecipeContainer using the _manage @@ -306,7 +306,7 @@ def _remove_object(self, obj, d): return - def _locateManagedObject(self, obj): + def _locate_managed_object(self, obj): """Find the location a managed object within the hierarchy. Attributes @@ -334,9 +334,9 @@ def _locateManagedObject(self, obj): return loc # Check within managed objects - if hasattr(m, "_locateManagedObject"): + if hasattr(m, "_locate_managed_object"): - subloc = m._locateManagedObject(obj) + subloc = m._locate_managed_object(obj) if subloc: return loc + subloc @@ -1008,7 +1008,7 @@ def _formatConstraints(self): # Find each constraint and format the equation clines = [] for par, con in cdict.items(): - loc = self._locateManagedObject(par) + loc = self._locate_managed_object(par) if loc: locstr = ".".join(o.name for o in loc[1:]) clines.append("%s <-- %s" % (locstr, con.eqstr)) diff --git a/tests/test_recipeorganizer.py b/tests/test_recipeorganizer.py index 3bb69789..724e1e80 100644 --- a/tests/test_recipeorganizer.py +++ b/tests/test_recipeorganizer.py @@ -139,27 +139,27 @@ def testLocateManagedObject(self): p3 = Parameter("p3", 3) # Locate m2 in m1 (m1.m2) - loc = m1._locateManagedObject(m2) + loc = m1._locate_managed_object(m2) self.assertEqual(loc, [m1, m2]) # Locate p1 (m1.p1) - loc = m1._locateManagedObject(p1) + loc = m1._locate_managed_object(p1) self.assertEqual(loc, [m1, p1]) # Locate p2 in m2 (m2.p2) - loc = m2._locateManagedObject(p2) + loc = m2._locate_managed_object(p2) self.assertEqual(loc, [m2, p2]) # Locate p2 in m1 (m1.m2.p2) - loc = m1._locateManagedObject(p2) + loc = m1._locate_managed_object(p2) self.assertEqual(loc, [m1, m2, p2]) # Locate p3 in m1 (not there) - loc = m1._locateManagedObject(p3) + loc = m1._locate_managed_object(p3) self.assertEqual(loc, []) # Locate p3 in m2 (not there) - loc = m2._locateManagedObject(p3) + loc = m2._locate_managed_object(p3) self.assertEqual(loc, []) return From c430287213b60744a18efe99bfe5f14d2fb1a27f Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:31:33 -0500 Subject: [PATCH 16/59] _add_parameter --- src/diffpy/srfit/fitbase/fitcontribution.py | 2 +- src/diffpy/srfit/fitbase/fitrecipe.py | 2 +- src/diffpy/srfit/fitbase/parameterset.py | 2 +- src/diffpy/srfit/fitbase/recipeorganizer.py | 8 +++--- src/diffpy/srfit/interface/interface.py | 6 ++--- tests/test_contribution.py | 2 +- tests/test_recipeorganizer.py | 30 ++++++++++----------- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitcontribution.py b/src/diffpy/srfit/fitbase/fitcontribution.py index 80463a12..5db67996 100644 --- a/src/diffpy/srfit/fitbase/fitcontribution.py +++ b/src/diffpy/srfit/fitbase/fitcontribution.py @@ -231,7 +231,7 @@ def setEquation(self, eqstr, ns={}): # Register any new Parameters. for par in self._eqfactory.newargs: - self._addParameter(par) + self._add_parameter(par) # Register eq as an operator self._eqfactory.registerOperator("eq", eq) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 18fbee52..fc3f8441 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -533,7 +533,7 @@ def addVar( if value is not None: var.setValue(value) - self._addParameter(var) + self._add_parameter(var) if fixed: self.fix(var) diff --git a/src/diffpy/srfit/fitbase/parameterset.py b/src/diffpy/srfit/fitbase/parameterset.py index fc61dfea..0e2bba99 100644 --- a/src/diffpy/srfit/fitbase/parameterset.py +++ b/src/diffpy/srfit/fitbase/parameterset.py @@ -83,7 +83,7 @@ def __init__(self, name): return # Alias Parameter accessors. - addParameter = RecipeOrganizer._addParameter + addParameter = RecipeOrganizer._add_parameter newParameter = RecipeOrganizer._new_parameter removeParameter = RecipeOrganizer._removeParameter diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index ec4cfcf7..3c6dea1a 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -424,15 +424,15 @@ def _new_parameter(self, name, value, check=True): """Add a new Parameter to the container. This creates a new Parameter and adds it to the container using - the _addParameter method. + the _add_parameter method. Returns the Parameter. """ p = Parameter(name, value) - self._addParameter(p, check) + self._add_parameter(p, check) return p - def _addParameter(self, par, check=True): + def _add_parameter(self, par, check=True): """Store a Parameter. Parameters added in this way are registered with the _eqfactory. @@ -649,7 +649,7 @@ def registerStringFunction(self, fstr, name, ns={}): # Register any new Parameters. for par in self._eqfactory.newargs: - self._addParameter(par) + self._add_parameter(par) # Register the equation as a callable function. argnames = eq.argdict.keys() diff --git a/src/diffpy/srfit/interface/interface.py b/src/diffpy/srfit/interface/interface.py index b547173e..63ccb573 100644 --- a/src/diffpy/srfit/interface/interface.py +++ b/src/diffpy/srfit/interface/interface.py @@ -81,19 +81,19 @@ def __imod__(self, args): return self def __iadd__(self, args): - """_new_parameter or _addParameter with += + """_new_parameter or _add_parameter with += Think of "+" as addition of a Parameter. This accepts arguments for a single function call. """ - # Want to detect _addParameter or _new_parameter + # Want to detect _add_parameter or _new_parameter def f(*args): if isinstance(args[0], six.string_types): self._new_parameter(*args) else: - self._addParameter(*args) + self._add_parameter(*args) return _applyargs(args, f) diff --git a/tests/test_contribution.py b/tests/test_contribution.py index 4d3fc7e3..48863e4d 100644 --- a/tests/test_contribution.py +++ b/tests/test_contribution.py @@ -223,7 +223,7 @@ def testResidual(noObserversInGlobalBuilders): # Try to add a parameter c = Parameter("c", 2) - fc._addParameter(c) + fc._add_parameter(c) fc.setEquation("c*I") assert fc._eq._value is None assert fc._reseq._value is None diff --git a/tests/test_recipeorganizer.py b/tests/test_recipeorganizer.py index 724e1e80..76974cbe 100644 --- a/tests/test_recipeorganizer.py +++ b/tests/test_recipeorganizer.py @@ -186,7 +186,7 @@ def testNewParameter(self): m = self.m p1 = Parameter("p1", 1) - m._addParameter(p1) + m._add_parameter(p1) # Test duplication of Parameters self.assertRaises(ValueError, m._new_parameter, "p1", 0) @@ -205,15 +205,15 @@ def testAddParameter(self): p2 = Parameter("p1", 2) # Check normal insert - m._addParameter(p1) + m._add_parameter(p1) self.assertTrue(m.p1 is p1) self.assertTrue(p1.name in m._eqfactory.builders) # Try to insert another parameter with the same name - self.assertRaises(ValueError, m._addParameter, p2) + self.assertRaises(ValueError, m._add_parameter, p2) # Now allow this - m._addParameter(p2, check=False) + m._add_parameter(p2, check=False) self.assertTrue(m.p1 is p2) self.assertTrue(p1.name in m._eqfactory.builders) @@ -223,10 +223,10 @@ def testAddParameter(self): m._add_object(c, m._containers) p3 = Parameter("test", 0) - self.assertRaises(ValueError, m._addParameter, p3) + self.assertRaises(ValueError, m._add_parameter, p3) p4 = Parameter("xyz", 0) - m._addParameter(p4) + m._add_parameter(p4) # Check order self.assertEqual(list(m._parameters.keys()), ["p1", "xyz"]) @@ -242,7 +242,7 @@ def testRemoveParameter(self): p1 = Parameter("p1", 1) p2 = Parameter("p1", 2) - m._addParameter(p1) + m._add_parameter(p1) # Check for bad remove self.assertRaises(ValueError, m._removeParameter, p2) @@ -335,11 +335,11 @@ def testGetConstraints(self): p3 = Parameter("p3", 3) p4 = Parameter("p4", 4) - self.m._addParameter(p1) - self.m._addParameter(p2) + self.m._add_parameter(p1) + self.m._add_parameter(p2) - m2._addParameter(p3) - m2._addParameter(p4) + m2._add_parameter(p3) + m2._add_parameter(p4) self.m.constrain(p1, "p2") m2.constrain(p3, "p4") @@ -362,11 +362,11 @@ def testGetRestraints(self): p3 = Parameter("p3", 3) p4 = Parameter("p4", 4) - self.m._addParameter(p1) - self.m._addParameter(p2) + self.m._add_parameter(p1) + self.m._add_parameter(p2) - m2._addParameter(p3) - m2._addParameter(p4) + m2._add_parameter(p3) + m2._add_parameter(p4) r1 = self.m.restrain("p1 + p2") r2 = m2.restrain("2*p3 + p4") From df663464fb1e98a1e78cfa83f7f05486106f1c00 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:32:08 -0500 Subject: [PATCH 17/59] _remove_parameter --- src/diffpy/srfit/fitbase/fitrecipe.py | 2 +- src/diffpy/srfit/fitbase/parameterset.py | 2 +- src/diffpy/srfit/fitbase/recipeorganizer.py | 4 ++-- tests/test_recipeorganizer.py | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index fc3f8441..b12a6365 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -561,7 +561,7 @@ def delVar(self, var): Raises ValueError if var is not part of the FitRecipe. """ - self._removeParameter(var) + self._remove_parameter(var) self._tagmanager.untag(var) return diff --git a/src/diffpy/srfit/fitbase/parameterset.py b/src/diffpy/srfit/fitbase/parameterset.py index 0e2bba99..ce89326f 100644 --- a/src/diffpy/srfit/fitbase/parameterset.py +++ b/src/diffpy/srfit/fitbase/parameterset.py @@ -85,7 +85,7 @@ def __init__(self, name): # Alias Parameter accessors. addParameter = RecipeOrganizer._add_parameter newParameter = RecipeOrganizer._new_parameter - removeParameter = RecipeOrganizer._removeParameter + removeParameter = RecipeOrganizer._remove_parameter def addParameterSet(self, parset): """Add a ParameterSet to the hierarchy. diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index 3c6dea1a..68ca9bf9 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -210,7 +210,7 @@ def __delattr__(self, name): general way. """ if name in self._parameters: - self._removeParameter(self._parameters[name]) + self._remove_parameter(self._parameters[name]) return m = self.get(name) @@ -458,7 +458,7 @@ def _add_parameter(self, par, check=True): self._eqfactory.registerArgument(par.name, par) return - def _removeParameter(self, par): + def _remove_parameter(self, par): """Remove a parameter. This de-registers the Parameter with the _eqfactory. The diff --git a/tests/test_recipeorganizer.py b/tests/test_recipeorganizer.py index 76974cbe..c015ae85 100644 --- a/tests/test_recipeorganizer.py +++ b/tests/test_recipeorganizer.py @@ -245,18 +245,18 @@ def testRemoveParameter(self): m._add_parameter(p1) # Check for bad remove - self.assertRaises(ValueError, m._removeParameter, p2) + self.assertRaises(ValueError, m._remove_parameter, p2) # Remove p1 - m._removeParameter(p1) + m._remove_parameter(p1) self.assertTrue(p1.name not in m._eqfactory.builders) # Try to remove it again - self.assertRaises(ValueError, m._removeParameter, p1) + self.assertRaises(ValueError, m._remove_parameter, p1) # Try to remove a RecipeContainer c = RecipeContainer("test") - self.assertRaises(ValueError, m._removeParameter, c) + self.assertRaises(ValueError, m._remove_parameter, c) return def testConstrain(self): From d3cb4c9355ea4751fe87be3047a1fec555ffe654 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:32:53 -0500 Subject: [PATCH 18/59] _get_constraints --- src/diffpy/srfit/fitbase/fitrecipe.py | 2 +- src/diffpy/srfit/fitbase/recipeorganizer.py | 12 ++++++------ tests/test_recipeorganizer.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index b12a6365..1640449b 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -431,7 +431,7 @@ def __collect_constraints_and_restraints(self): for org in chain(self._contributions.values(), self._parsets.values()): rset.update(org._getRestraints()) - cdict.update(org._getConstraints()) + cdict.update(org._get_constraints()) cdict.update(self._constraints) # The order of the restraint list does not matter diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index 68ca9bf9..9410e9a5 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -374,7 +374,7 @@ class RecipeOrganizer(_recipeorganizer_interface, RecipeContainer): Restraints, as well as Equations that can be used in Constraint and Restraint equations. These constraints and Restraints can be placed at any level and a flattened list of them can be retrieved with the - _getConstraints and _getRestraints methods. + _get_constraints and _getRestraints methods. Attributes ---------- @@ -797,7 +797,7 @@ def getConstrainedPars(self, recurse=False): Recurse into managed objects and retrieve their constrained Parameters as well (default False). """ - const = self._getConstraints(recurse) + const = self._get_constraints(recurse) return const.keys() def clearConstraints(self, recurse=False): @@ -921,12 +921,12 @@ def clearRestraints(self, recurse=False): msg.clearRestraints(recurse) return - def _getConstraints(self, recurse=True): + def _get_constraints(self, recurse=True): """Get the constrained Parameters for this and managed sub-objects.""" constraints = {} if recurse: for m in filter(_has_get_constraints, self._iter_managed()): - constraints.update(m._getConstraints(recurse)) + constraints.update(m._get_constraints(recurse)) constraints.update(self._constraints) @@ -1004,7 +1004,7 @@ def _formatConstraints(self): List of formatted lines displaying the defined constraints. Return empty list when no constraints were defined. """ - cdict = self._getConstraints() + cdict = self._get_constraints() # Find each constraint and format the equation clines = [] for par, con in cdict.items(): @@ -1169,7 +1169,7 @@ def _has_get_restraints(msg): def _has_get_constraints(msg): - return hasattr(msg, "_getConstraints") + return hasattr(msg, "_get_constraints") def _pmatch(inp_str, regexp): diff --git a/tests/test_recipeorganizer.py b/tests/test_recipeorganizer.py index c015ae85..bf76a70c 100644 --- a/tests/test_recipeorganizer.py +++ b/tests/test_recipeorganizer.py @@ -324,7 +324,7 @@ def testRestrain(self): return def testGetConstraints(self): - """Test the _getConstraints method.""" + """Test the _get_constraints method.""" m2 = RecipeOrganizer("m2") self.m._organizers = {} self.m._manage(self.m._organizers) @@ -344,7 +344,7 @@ def testGetConstraints(self): self.m.constrain(p1, "p2") m2.constrain(p3, "p4") - cons = self.m._getConstraints() + cons = self.m._get_constraints() self.assertTrue(p1 in cons) self.assertTrue(p3 in cons) self.assertEqual(2, len(cons)) From 60d83227ddad0d2d38d9490b86b25830c094537c Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:33:13 -0500 Subject: [PATCH 19/59] _get_restraints --- src/diffpy/srfit/fitbase/fitrecipe.py | 2 +- src/diffpy/srfit/fitbase/recipeorganizer.py | 10 +++++----- tests/test_recipeorganizer.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 1640449b..ffc1d595 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -430,7 +430,7 @@ def __collect_constraints_and_restraints(self): cdict = {} for org in chain(self._contributions.values(), self._parsets.values()): - rset.update(org._getRestraints()) + rset.update(org._get_restraints()) cdict.update(org._get_constraints()) cdict.update(self._constraints) diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index 9410e9a5..3b38aeba 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -374,7 +374,7 @@ class RecipeOrganizer(_recipeorganizer_interface, RecipeContainer): Restraints, as well as Equations that can be used in Constraint and Restraint equations. These constraints and Restraints can be placed at any level and a flattened list of them can be retrieved with the - _get_constraints and _getRestraints methods. + _get_constraints and _get_restraints methods. Attributes ---------- @@ -932,7 +932,7 @@ def _get_constraints(self, recurse=True): return constraints - def _getRestraints(self, recurse=True): + def _get_restraints(self, recurse=True): """Get the Restraints for this and embedded ParameterSets. This returns a set of Restraint objects. @@ -940,7 +940,7 @@ def _getRestraints(self, recurse=True): restraints = set(self._restraints) if recurse: for m in filter(_has_get_restraints, self._iter_managed()): - restraints.update(m._getRestraints(recurse)) + restraints.update(m._get_restraints(recurse)) return restraints @@ -1029,7 +1029,7 @@ def _formatRestraints(self): List of formatted lines displaying the defined restraints. Return empty list when no restraints were defined. """ - rset = self._getRestraints() + rset = self._get_restraints() rlines = [] for res in rset: line = "%s: lb = %f, ub = %f, sig = %f, scaled = %s" % ( @@ -1165,7 +1165,7 @@ def _has_clear_restraints(msg): def _has_get_restraints(msg): - return hasattr(msg, "_getRestraints") + return hasattr(msg, "_get_restraints") def _has_get_constraints(msg): diff --git a/tests/test_recipeorganizer.py b/tests/test_recipeorganizer.py index bf76a70c..a5db1e1b 100644 --- a/tests/test_recipeorganizer.py +++ b/tests/test_recipeorganizer.py @@ -351,7 +351,7 @@ def testGetConstraints(self): return def testGetRestraints(self): - """Test the _getRestraints method.""" + """Test the _get_restraints method.""" m2 = RecipeOrganizer("m2") self.m._organizers = {} self.m._manage(self.m._organizers) @@ -371,7 +371,7 @@ def testGetRestraints(self): r1 = self.m.restrain("p1 + p2") r2 = m2.restrain("2*p3 + p4") - res = self.m._getRestraints() + res = self.m._get_restraints() self.assertTrue(r1 in res) self.assertTrue(r2 in res) self.assertEqual(2, len(res)) From ba289fc7611ba85d7e2d5e0ccb9634691bf8b1e1 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:33:46 -0500 Subject: [PATCH 20/59] _format_constraints --- src/diffpy/srfit/fitbase/recipeorganizer.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index 3b38aeba..6ea21dc5 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -959,7 +959,7 @@ def _validate(self): # For printing the configured recipe to screen - def _formatManaged(self, prefix=""): + def _format_managed(self, prefix=""): """Format hierarchy of managed parameters for showing. Parameters @@ -985,14 +985,14 @@ def _formatManaged(self, prefix=""): ) # Recurse into managed objects. for obj in self._iter_managed(): - if hasattr(obj, "_formatManaged"): + if hasattr(obj, "_format_managed"): oprefix = prefix + obj.name + "." - tlines = obj._formatManaged(prefix=oprefix) + tlines = obj._format_managed(prefix=oprefix) lines.extend([""] if lines and tlines else []) lines.extend(tlines) return lines - def _formatConstraints(self): + def _format_constraints(self): """Format constraints for showing. This collects constraints on all levels of the hierarchy and displays @@ -1061,7 +1061,7 @@ def show(self, pattern="", textwidth=78): _pmatch_with_re = partial(_pmatch, regexp=regexp) # Show sub objects and their parameters lines = [] - tlines = self._formatManaged() + tlines = self._format_managed() if tlines: lines.extend(["Parameters", _DASHEDLINE]) linesok = filter(_pmatch_with_re, tlines) @@ -1076,7 +1076,7 @@ def show(self, pattern="", textwidth=78): # FIXME - parameter names in equations not particularly informative # Show constraints cmatch = regexp.search - tlines = self._formatConstraints() + tlines = self._format_constraints() if tlines: if lines: lines.append("") From 06a37eb22a395bf1d4024131e347e8969ac26098 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:34:06 -0500 Subject: [PATCH 21/59] _format_restraints --- src/diffpy/srfit/fitbase/recipeorganizer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index 6ea21dc5..166719ee 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -1017,7 +1017,7 @@ def _format_constraints(self): clines.sort(key=numstr) return clines - def _formatRestraints(self): + def _format_restraints(self): """Format restraints for showing. This collects restraints on all levels of the hierarchy and displays @@ -1085,7 +1085,7 @@ def show(self, pattern="", textwidth=78): # FIXME - parameter names in equations not particularly informative # Show restraints - tlines = self._formatRestraints() + tlines = self._format_restraints() if tlines: if lines: lines.append("") From 2b62174f9bb76d265e574ac53af39fc747c84a2d Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:35:21 -0500 Subject: [PATCH 22/59] _validate_others --- src/diffpy/srfit/fitbase/recipeorganizer.py | 4 ++-- src/diffpy/srfit/fitbase/validatable.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index 166719ee..3b95a216 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -360,7 +360,7 @@ def _validate(self): Raises AttributeError if validation fails. """ iterable = chain(self.__iter__(), self._iter_managed()) - self._validateOthers(iterable) + self._validate_others(iterable) return @@ -954,7 +954,7 @@ def _validate(self): """ RecipeContainer._validate(self) iterable = chain(self._restraints, self._constraints.values()) - self._validateOthers(iterable) + self._validate_others(iterable) return # For printing the configured recipe to screen diff --git a/src/diffpy/srfit/fitbase/validatable.py b/src/diffpy/srfit/fitbase/validatable.py index a3aeac66..5a28b132 100644 --- a/src/diffpy/srfit/fitbase/validatable.py +++ b/src/diffpy/srfit/fitbase/validatable.py @@ -27,7 +27,7 @@ class Validatable(object): A Validatable has state that must be validated by a FitRecipe. """ - def _validateOthers(self, iterable): + def _validate_others(self, iterable): """Method to validate configuration of Validatables in iterable. This is provided as a convenience for derived classes. No need From e72e7040d76f68d2d187c5b92877a85309494253 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:36:27 -0500 Subject: [PATCH 23/59] _set_calculator --- src/diffpy/srfit/pdf/basepdfgenerator.py | 2 +- src/diffpy/srfit/pdf/debyepdfgenerator.py | 2 +- src/diffpy/srfit/pdf/pdfgenerator.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffpy/srfit/pdf/basepdfgenerator.py b/src/diffpy/srfit/pdf/basepdfgenerator.py index da867bca..20c33f5d 100644 --- a/src/diffpy/srfit/pdf/basepdfgenerator.py +++ b/src/diffpy/srfit/pdf/basepdfgenerator.py @@ -108,7 +108,7 @@ def __init__(self, name="pdf"): _parnames = ["delta1", "delta2", "qbroad", "scale", "qdamp"] - def _setCalculator(self, calc): + def _set_calculator(self, calc): """Set the SrReal calculator instance. Setting the calculator creates Parameters from the variable diff --git a/src/diffpy/srfit/pdf/debyepdfgenerator.py b/src/diffpy/srfit/pdf/debyepdfgenerator.py index 8b359779..641c577f 100644 --- a/src/diffpy/srfit/pdf/debyepdfgenerator.py +++ b/src/diffpy/srfit/pdf/debyepdfgenerator.py @@ -135,7 +135,7 @@ def __init__(self, name="pdf"): from diffpy.srreal.pdfcalculator import DebyePDFCalculator BasePDFGenerator.__init__(self, name) - self._setCalculator(DebyePDFCalculator()) + self._set_calculator(DebyePDFCalculator()) return diff --git a/src/diffpy/srfit/pdf/pdfgenerator.py b/src/diffpy/srfit/pdf/pdfgenerator.py index 3f30cb0c..3a2f919b 100644 --- a/src/diffpy/srfit/pdf/pdfgenerator.py +++ b/src/diffpy/srfit/pdf/pdfgenerator.py @@ -88,7 +88,7 @@ def __init__(self, name="pdf"): from diffpy.srreal.pdfcalculator import PDFCalculator BasePDFGenerator.__init__(self, name) - self._setCalculator(PDFCalculator()) + self._set_calculator(PDFCalculator()) return From 8b7de3e43f229d2fa32c90f5f02453998c8039c3 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:37:47 -0500 Subject: [PATCH 24/59] _setup_generator --- src/diffpy/srfit/pdf/pdfcontribution.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffpy/srfit/pdf/pdfcontribution.py b/src/diffpy/srfit/pdf/pdfcontribution.py index 68bdac86..3b7db5da 100644 --- a/src/diffpy/srfit/pdf/pdfcontribution.py +++ b/src/diffpy/srfit/pdf/pdfcontribution.py @@ -217,7 +217,7 @@ def addStructure(self, name, stru, periodic=True): # Set up the generator gen.setStructure(stru, "phase", periodic) - self._setupGenerator(gen) + self._setup_generator(gen) return gen.phase @@ -262,11 +262,11 @@ def addPhase(self, name, parset, periodic=True): # Set up the generator gen.setPhase(parset, periodic) - self._setupGenerator(gen) + self._setup_generator(gen) return gen.phase - def _setupGenerator(self, gen): + def _setup_generator(self, gen): """Setup a generator. The generator must already have a managed SrRealParSet, added From 67834ea95d74da57f7b6d08e139c110023fedcac Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:38:17 -0500 Subject: [PATCH 25/59] _get_meta_value --- src/diffpy/srfit/pdf/pdfcontribution.py | 8 ++++---- tests/test_pdf.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/diffpy/srfit/pdf/pdfcontribution.py b/src/diffpy/srfit/pdf/pdfcontribution.py index 3b7db5da..2679a3ff 100644 --- a/src/diffpy/srfit/pdf/pdfcontribution.py +++ b/src/diffpy/srfit/pdf/pdfcontribution.py @@ -293,7 +293,7 @@ def _setup_generator(self, gen): # Calculation setup methods - def _getMetaValue(self, kwd): + def _get_meta_value(self, kwd): """Get metadata according to object hierarchy.""" # Check self, then generators then profile if kwd in self._meta: @@ -324,7 +324,7 @@ def getScatteringType(self): See 'setScatteringType'. """ - return self._getMetaValue("stype") + return self._get_meta_value("stype") def setQmax(self, qmax): """Set the qmax value.""" @@ -335,7 +335,7 @@ def setQmax(self, qmax): def getQmax(self): """Get the qmax value.""" - return self._getMetaValue("qmax") + return self._get_meta_value("qmax") def setQmin(self, qmin): """Set the qmin value.""" @@ -346,7 +346,7 @@ def setQmin(self, qmin): def getQmin(self): """Get the qmin value.""" - return self._getMetaValue("qmin") + return self._get_meta_value("qmin") # End of file diff --git a/tests/test_pdf.py b/tests/test_pdf.py index 1ee2ccec..b46fa2a6 100644 --- a/tests/test_pdf.py +++ b/tests/test_pdf.py @@ -242,7 +242,7 @@ def test_getQmax(diffpy_structure_available, diffpy_srreal_available): if not diffpy_srreal_available: pytest.skip("diffpy.srreal package not available") - # cover all code branches in PDFContribution._getMetaValue + # cover all code branches in PDFContribution._get_meta_value # (1) contribution metadata pc1 = PDFContribution("pdf") assert pc1.getQmax() is None From c92e179e1ba0ed633d3659c289347294526d708d Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:41:10 -0500 Subject: [PATCH 26/59] _getelem --- src/diffpy/srfit/structure/cctbxparset.py | 4 ++-- src/diffpy/srfit/structure/diffpyparset.py | 4 ++-- src/diffpy/srfit/structure/objcrystparset.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/diffpy/srfit/structure/cctbxparset.py b/src/diffpy/srfit/structure/cctbxparset.py index fd56a2f3..41f174da 100644 --- a/src/diffpy/srfit/structure/cctbxparset.py +++ b/src/diffpy/srfit/structure/cctbxparset.py @@ -120,10 +120,10 @@ def _setuiso(self, dummy, value): self.strups.stru.scatterers()[self.idx].u_iso = value return - def _getElem(self): + def _getelem(self): return self.stru.element_symbol() - element = property(_getElem) + element = property(_getelem) # End class CCTBXScattererParSet diff --git a/src/diffpy/srfit/structure/diffpyparset.py b/src/diffpy/srfit/structure/diffpyparset.py index 7263e1f0..3bae35af 100644 --- a/src/diffpy/srfit/structure/diffpyparset.py +++ b/src/diffpy/srfit/structure/diffpyparset.py @@ -151,13 +151,13 @@ def __init__(self, name, atom): def __repr__(self): return repr(self.atom) - def _getElem(self): + def _getelem(self): return self.atom.element def _setElem(self, el): self.atom.element = el - element = property(_getElem, _setElem, "type of atom") + element = property(_getelem, _setElem, "type of atom") # End class DiffpyAtomParSet diff --git a/src/diffpy/srfit/structure/objcrystparset.py b/src/diffpy/srfit/structure/objcrystparset.py index dec7917f..9cfbfef3 100644 --- a/src/diffpy/srfit/structure/objcrystparset.py +++ b/src/diffpy/srfit/structure/objcrystparset.py @@ -179,11 +179,11 @@ def __init__(self, name, atom, parent): self.Biso.value = 0.5 return - def _getElem(self): + def _getelem(self): """Getter for the element type.""" return self.scat.GetScatteringPower().GetSymbol() - element = property(_getElem) + element = property(_getelem) # End class ObjCrystAtomParSet @@ -809,7 +809,7 @@ def __init__(self, name, scat, parent): return - def _getElem(self): + def _getelem(self): """Getter for the element type.""" sp = self.scat.GetScatteringPower() if sp: @@ -817,7 +817,7 @@ def _getElem(self): else: return "dummy" - element = property(_getElem) + element = property(_getelem) def isDummy(self): """Indicate whether this atom is a dummy atom.""" From 98bfed3d91aaa268746323de35dd4853398fb3eb Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:42:10 -0500 Subject: [PATCH 27/59] _setelem --- src/diffpy/srfit/structure/diffpyparset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/diffpyparset.py b/src/diffpy/srfit/structure/diffpyparset.py index 3bae35af..172a7551 100644 --- a/src/diffpy/srfit/structure/diffpyparset.py +++ b/src/diffpy/srfit/structure/diffpyparset.py @@ -154,10 +154,10 @@ def __repr__(self): def _getelem(self): return self.atom.element - def _setElem(self, el): + def _setelem(self, el): self.atom.element = el - element = property(_getelem, _setElem, "type of atom") + element = property(_getelem, _setelem, "type of atom") # End class DiffpyAtomParSet From b3850c3ed09e4a7f7181e1b17baa52045d99ebfe Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:42:51 -0500 Subject: [PATCH 28/59] _get_srreal_structure --- src/diffpy/srfit/pdf/basepdfgenerator.py | 2 +- src/diffpy/srfit/structure/bvsrestraint.py | 2 +- src/diffpy/srfit/structure/diffpyparset.py | 4 ++-- src/diffpy/srfit/structure/objcrystparset.py | 2 +- src/diffpy/srfit/structure/srrealparset.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/diffpy/srfit/pdf/basepdfgenerator.py b/src/diffpy/srfit/pdf/basepdfgenerator.py index 20c33f5d..e91023e8 100644 --- a/src/diffpy/srfit/pdf/basepdfgenerator.py +++ b/src/diffpy/srfit/pdf/basepdfgenerator.py @@ -320,7 +320,7 @@ def __call__(self, r): if not numpy.array_equal(r, self._lastr): self._prepare(r) - rcalc, y = self._calc(self._phase._getSrRealStructure()) + rcalc, y = self._calc(self._phase._get_srreal_structure()) if numpy.isnan(y).any(): y = numpy.zeros_like(r) diff --git a/src/diffpy/srfit/structure/bvsrestraint.py b/src/diffpy/srfit/structure/bvsrestraint.py index da00b397..f8af1ebe 100644 --- a/src/diffpy/srfit/structure/bvsrestraint.py +++ b/src/diffpy/srfit/structure/bvsrestraint.py @@ -76,7 +76,7 @@ def penalty(self, w=1.0): penalty (float, default 1.0). """ # Get the bvms from the BVSCalculator - stru = self._parset._getSrRealStructure() + stru = self._parset._get_srreal_structure() self._calc.eval(stru) penalty = self._calc.bvmsdiff diff --git a/src/diffpy/srfit/structure/diffpyparset.py b/src/diffpy/srfit/structure/diffpyparset.py index 172a7551..6ed3beef 100644 --- a/src/diffpy/srfit/structure/diffpyparset.py +++ b/src/diffpy/srfit/structure/diffpyparset.py @@ -326,7 +326,7 @@ def getScatterers(self): """ return self.atoms - def _getSrRealStructure(self): + def _get_srreal_structure(self): """Get the structure object for use with SrReal calculators. If this is periodic, then return the structure, otherwise, pass @@ -335,7 +335,7 @@ def _getSrRealStructure(self): """ from diffpy.srreal.structureadapter import nometa - stru = SrRealParSet._getSrRealStructure(self) + stru = SrRealParSet._get_srreal_structure(self) return nometa(stru) diff --git a/src/diffpy/srfit/structure/objcrystparset.py b/src/diffpy/srfit/structure/objcrystparset.py index 9cfbfef3..9979c5b1 100644 --- a/src/diffpy/srfit/structure/objcrystparset.py +++ b/src/diffpy/srfit/structure/objcrystparset.py @@ -282,7 +282,7 @@ def usingSymmetry(self): return False # Part of SrRealParSet interface - def _getSrRealStructure(self): + def _get_srreal_structure(self): """Get the structure object for use with SrReal calculators. Molecule objects are never periodic. Return the object and let diff --git a/src/diffpy/srfit/structure/srrealparset.py b/src/diffpy/srfit/structure/srrealparset.py index cb5f95fe..5a5e5028 100644 --- a/src/diffpy/srfit/structure/srrealparset.py +++ b/src/diffpy/srfit/structure/srrealparset.py @@ -86,7 +86,7 @@ def usingSymmetry(self): """Check if symmetry is being used.""" return self._usesymmetry - def _getSrRealStructure(self): + def _get_srreal_structure(self): """Get the structure object for use with SrReal calculators. If this is periodic, then return the structure, otherwise, pass From 9ad376ac3f14fd4bfd0ca4b6b3e2b53a15a5852d Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:44:39 -0500 Subject: [PATCH 29/59] _constrain_space_group --- src/diffpy/srfit/structure/cctbxparset.py | 4 ++-- src/diffpy/srfit/structure/objcrystparset.py | 4 ++-- tests/test_sgconstraints.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/diffpy/srfit/structure/cctbxparset.py b/src/diffpy/srfit/structure/cctbxparset.py index 41f174da..2bb05c7d 100644 --- a/src/diffpy/srfit/structure/cctbxparset.py +++ b/src/diffpy/srfit/structure/cctbxparset.py @@ -253,10 +253,10 @@ def __init__(self, name, stru): self.scatterers.append(scatterer) # Constrain the lattice - from diffpy.srfit.structure.sgconstraints import _constrainSpaceGroup + from diffpy.srfit.structure.sgconstraints import _constrain_space_group symbol = self.getSpaceGroup() - _constrainSpaceGroup(self, symbol) + _constrain_space_group(self, symbol) return diff --git a/src/diffpy/srfit/structure/objcrystparset.py b/src/diffpy/srfit/structure/objcrystparset.py index 9979c5b1..d2a32962 100644 --- a/src/diffpy/srfit/structure/objcrystparset.py +++ b/src/diffpy/srfit/structure/objcrystparset.py @@ -1766,7 +1766,7 @@ def __init__(self, name, cryst): return - def _constrainSpaceGroup(self): + def _constrain_space_group(self): """Constrain the space group.""" if self._sgpars is not None: return self._sgpars @@ -1786,7 +1786,7 @@ def _constrainSpaceGroup(self): ) return self._sgpars - sgpars = property(_constrainSpaceGroup) + sgpars = property(_constrain_space_group) @staticmethod def _createSpaceGroup(sgobjcryst): diff --git a/tests/test_sgconstraints.py b/tests/test_sgconstraints.py index f0696321..8c9b52e9 100644 --- a/tests/test_sgconstraints.py +++ b/tests/test_sgconstraints.py @@ -22,7 +22,7 @@ # ---------------------------------------------------------------------------- -def test_ObjCryst_constrainSpaceGroup(pyobjcryst_available): +def test_ObjCryst_constrain_space_group(pyobjcryst_available): """Make sure that all Parameters are constrained properly. This tests constrainSpaceGroup from @@ -39,7 +39,7 @@ def test_ObjCryst_constrainSpaceGroup(pyobjcryst_available): occryst = makeLaMnO3() stru = ObjCrystCrystalParSet(occryst.GetName(), occryst) # Make sure we actually create the constraints - stru._constrainSpaceGroup() + stru._constrain_space_group() # Make the space group parameters individually stru.sgpars.latpars stru.sgpars.xyzpars From 26cd321df51e9d831bf27f3108e4bd3cd6dce976 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:45:03 -0500 Subject: [PATCH 30/59] _create_space_group --- src/diffpy/srfit/structure/objcrystparset.py | 4 ++-- tests/test_objcrystparset.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffpy/srfit/structure/objcrystparset.py b/src/diffpy/srfit/structure/objcrystparset.py index d2a32962..3e2202c7 100644 --- a/src/diffpy/srfit/structure/objcrystparset.py +++ b/src/diffpy/srfit/structure/objcrystparset.py @@ -1770,7 +1770,7 @@ def _constrain_space_group(self): """Constrain the space group.""" if self._sgpars is not None: return self._sgpars - sg = self._createSpaceGroup(self.stru.GetSpaceGroup()) + sg = self._create_space_group(self.stru.GetSpaceGroup()) from diffpy.srfit.structure.sgconstraints import _constrainAsSpaceGroup adpsymbols = ["B11", "B22", "B33", "B12", "B13", "B23"] @@ -1789,7 +1789,7 @@ def _constrain_space_group(self): sgpars = property(_constrain_space_group) @staticmethod - def _createSpaceGroup(sgobjcryst): + def _create_space_group(sgobjcryst): """Create a diffpy.structure SpaceGroup object from pyobjcryst. Attributes diff --git a/tests/test_objcrystparset.py b/tests/test_objcrystparset.py index c21a6d28..5150ae54 100644 --- a/tests/test_objcrystparset.py +++ b/tests/test_objcrystparset.py @@ -632,7 +632,7 @@ def getObjCrystParSetSpaceGroup(sg): from pyobjcryst.spacegroup import SpaceGroup sgobjcryst = SpaceGroup(sg.short_name) - sgnew = ObjCrystCrystalParSet._createSpaceGroup(sgobjcryst) + sgnew = ObjCrystCrystalParSet._create_space_group(sgobjcryst) return sgnew @staticmethod From dcdb243ee9ce03d9887b43d7941080d4b07a4444 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:47:50 -0500 Subject: [PATCH 31/59] _constrain_as_space_group --- src/diffpy/srfit/structure/objcrystparset.py | 6 ++++-- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- tests/test_sgconstraints.py | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/diffpy/srfit/structure/objcrystparset.py b/src/diffpy/srfit/structure/objcrystparset.py index 3e2202c7..19213b43 100644 --- a/src/diffpy/srfit/structure/objcrystparset.py +++ b/src/diffpy/srfit/structure/objcrystparset.py @@ -1771,12 +1771,14 @@ def _constrain_space_group(self): if self._sgpars is not None: return self._sgpars sg = self._create_space_group(self.stru.GetSpaceGroup()) - from diffpy.srfit.structure.sgconstraints import _constrainAsSpaceGroup + from diffpy.srfit.structure.sgconstraints import ( + _constrain_as_space_group, + ) adpsymbols = ["B11", "B22", "B33", "B12", "B13", "B23"] isosymbol = "Biso" sgoffset = [0, 0, 0] - self._sgpars = _constrainAsSpaceGroup( + self._sgpars = _constrain_as_space_group( self, sg, self.scatterers, diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 85f4b4f8..13d51a4a 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -108,7 +108,7 @@ def constrainAsSpaceGroup( sg = spacegroup if not isinstance(spacegroup, SpaceGroup): sg = GetSpaceGroup(spacegroup) - sgp = _constrainAsSpaceGroup( + sgp = _constrain_as_space_group( phase, sg, scatterers, @@ -122,7 +122,7 @@ def constrainAsSpaceGroup( return sgp -def _constrainAsSpaceGroup( +def _constrain_as_space_group( phase, sg, scatterers=None, diff --git a/tests/test_sgconstraints.py b/tests/test_sgconstraints.py index 8c9b52e9..32d6afe4 100644 --- a/tests/test_sgconstraints.py +++ b/tests/test_sgconstraints.py @@ -105,7 +105,7 @@ def test_ObjCryst_constrain_space_group(pyobjcryst_available): return -def test_DiffPy_constrainAsSpaceGroup(datafile, pyobjcryst_available): +def test_DiffPy_constrain_as_space_group(datafile, pyobjcryst_available): """Test the constrainAsSpaceGroup function.""" if not pyobjcryst_available: pytest.skip("pyobjcrysta package not available") @@ -178,7 +178,7 @@ def _alltests(par): return -def test_ConstrainAsSpaceGroup_args(pyobjcryst_available, datafile): +def test_constrain_as_space_group_args(pyobjcryst_available, datafile): """Test the arguments processing of constrainAsSpaceGroup function.""" if not pyobjcryst_available: pytest.skip("pyobjcrysta package not available") From a5c9d8ccbf6340b9444c77f6704485370884ac64 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:48:19 -0500 Subject: [PATCH 32/59] _get_lat_pars --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 13d51a4a..347962a0 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -320,9 +320,9 @@ def __iter__(self): self._makeConstraints() return RecipeContainer.__iter__(self) - latpars = property(lambda self: self._getLatPars()) + latpars = property(lambda self: self._get_lat_pars()) - def _getLatPars(self): + def _get_lat_pars(self): """Accessor for _latpars.""" if self._latpars is None: self._constrainLattice() From 7bad1defde1cbe10c09e1b01ec5b3bc8827a0eac Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:49:21 -0500 Subject: [PATCH 33/59] _get_xyz_pars --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 347962a0..9f119706 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -328,9 +328,9 @@ def _get_lat_pars(self): self._constrainLattice() return self._latpars - xyzpars = property(lambda self: self._getXYZPars()) + xyzpars = property(lambda self: self._get_xyz_pars()) - def _getXYZPars(self): + def _get_xyz_pars(self): """Accessor for _xyzpars.""" positions = [] for scatterer in self.scatterers: From 7393f082ec532e57d5049e54b0b9ec1f3a5f3962 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:49:43 -0500 Subject: [PATCH 34/59] _get_adp_pars --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 9f119706..f0ee0143 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -340,9 +340,9 @@ def _get_xyz_pars(self): self._constrainXYZs(positions) return self._xyzpars - adppars = property(lambda self: self._getADPPars()) + adppars = property(lambda self: self._get_adp_pars()) - def _getADPPars(self): + def _get_adp_pars(self): """Accessor for _adppars.""" positions = [] for scatterer in self.scatterers: From 730b8415f646da6c2f549e29205984aba569ff7b Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:50:13 -0500 Subject: [PATCH 35/59] _make_constraints --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index f0ee0143..2133554c 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -317,7 +317,7 @@ def __iter__(self): or self._xyzpars is None or self._adppars is None ): - self._makeConstraints() + self._make_constraints() return RecipeContainer.__iter__(self) latpars = property(lambda self: self._get_lat_pars()) @@ -352,7 +352,7 @@ def _get_adp_pars(self): self._constrainADPs(positions) return self._adppars - def _makeConstraints(self): + def _make_constraints(self): """Constrain the structure to the space group. This works as described by the constrainAsSpaceGroup method. From 44a35d608223ea75fec165f944dfac75aa9dac73 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:50:46 -0500 Subject: [PATCH 36/59] _clear_constraints --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 2133554c..ed176e46 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -359,7 +359,7 @@ def _make_constraints(self): """ # Start by clearing the constraints - self._clearConstraints() + self._clear_constraints() scatterers = self.scatterers @@ -375,7 +375,7 @@ def _make_constraints(self): return - def _clearConstraints(self): + def _clear_constraints(self): """Clear old constraints. This only clears constraints where new ones are going to be From 8c94299f743f5a8b3a5441691a9beb41aefd1d22 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:51:06 -0500 Subject: [PATCH 37/59] _constrain_lattice --- src/diffpy/srfit/structure/sgconstraints.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index ed176e46..1270108a 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -325,7 +325,7 @@ def __iter__(self): def _get_lat_pars(self): """Accessor for _latpars.""" if self._latpars is None: - self._constrainLattice() + self._constrain_lattice() return self._latpars xyzpars = property(lambda self: self._get_xyz_pars()) @@ -369,7 +369,7 @@ def _make_constraints(self): xyz = [scatterer.x, scatterer.y, scatterer.z] positions.append([p.value for p in xyz]) - self._constrainLattice() + self._constrain_lattice() self._constrainXYZs(positions) self._constrainADPs(positions) @@ -430,7 +430,7 @@ def _clear_constraints(self): return - def _constrainLattice(self): + def _constrain_lattice(self): """Constrain the lattice parameters.""" if not self.constrainlat: From 6bd9bfda5aae67ecdae98200ddfbccf132a8e9fb Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:51:33 -0500 Subject: [PATCH 38/59] _constrain_xyzs --- src/diffpy/srfit/structure/sgconstraints.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 1270108a..f3d52f39 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -337,7 +337,7 @@ def _get_xyz_pars(self): xyz = [scatterer.x, scatterer.y, scatterer.z] positions.append([p.value for p in xyz]) if self._xyzpars is None: - self._constrainXYZs(positions) + self._constrain_xyzs(positions) return self._xyzpars adppars = property(lambda self: self._get_adp_pars()) @@ -370,7 +370,7 @@ def _make_constraints(self): positions.append([p.value for p in xyz]) self._constrain_lattice() - self._constrainXYZs(positions) + self._constrain_xyzs(positions) self._constrainADPs(positions) return @@ -467,7 +467,7 @@ def _constrain_lattice(self): return - def _constrainXYZs(self, positions): + def _constrain_xyzs(self, positions): """Constrain the positions. Attributes From 70d701cc91a9697752b14b72bf6abf099bcf6013 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:51:52 -0500 Subject: [PATCH 39/59] _constrain_adps --- src/diffpy/srfit/structure/sgconstraints.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index f3d52f39..7390e343 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -349,7 +349,7 @@ def _get_adp_pars(self): xyz = [scatterer.x, scatterer.y, scatterer.z] positions.append([p.value for p in xyz]) if self._adppars is None: - self._constrainADPs(positions) + self._constrain_adps(positions) return self._adppars def _make_constraints(self): @@ -371,7 +371,7 @@ def _make_constraints(self): self._constrain_lattice() self._constrain_xyzs(positions) - self._constrainADPs(positions) + self._constrain_adps(positions) return @@ -482,7 +482,7 @@ def _constrain_xyzs(self, positions): sgoffset = self.sgoffset # We do this without ADPs here so we can skip much complication. See - # the _constrainADPs method for details. + # the _constrain_adps method for details. g = SymmetryConstraints(sg, positions, sgoffset=sgoffset) scatterers = self.scatterers @@ -510,7 +510,7 @@ def _constrain_xyzs(self, positions): return - def _constrainADPs(self, positions): + def _constrain_adps(self, positions): """Constrain the ADPs. Attributes From 20e048ac35a97124473bb8bc54ce30a1d8177fa2 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:52:17 -0500 Subject: [PATCH 40/59] __add_par --- src/diffpy/srfit/structure/sgconstraints.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 7390e343..928935f9 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -462,7 +462,7 @@ def _constrain_lattice(self): for par in pars: # FIXME - the original parameter will still appear as # constrained. - newpar = self.__addPar(par.name, par) + newpar = self.__add_par(par.name, par) self._latpars.addParameter(newpar) return @@ -494,7 +494,7 @@ def _constrain_xyzs(self, positions): name, idx = pname.rsplit("_", 1) idx = int(idx) par = scatterers[idx].get(name) - newpar = self.__addPar(pname, par) + newpar = self.__add_par(pname, par) self._xyzpars.addParameter(newpar) # Constrain non-free xyz parameters @@ -580,13 +580,13 @@ def _constrain_adps(self, positions): par = scatterer.get(isosymbol) if par is not None: parname = "%s_%i" % (isosymbol, idx) - newpar = self.__addPar(parname, par) + newpar = self.__add_par(parname, par) self._adppars.addParameter(newpar) isonames.append(newpar.name) else: par = scatterer.get(name) if par is not None: - newpar = self.__addPar(pname, par) + newpar = self.__add_par(pname, par) self._adppars.addParameter(newpar) # Constrain dependent isotropics @@ -613,7 +613,7 @@ def _constrain_adps(self, positions): pname, formula, scatterer, idx, self._parameters ) - def __addPar(self, parname, par): + def __add_par(self, parname, par): """Constrain a parameter via proxy with a specified name. Attributes From aca79b1fb6dcb252437a590cdb84e540bebe51da Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:52:45 -0500 Subject: [PATCH 41/59] _constrain_triclinic --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 928935f9..78ae9608 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -635,7 +635,7 @@ def __add_par(self, parname, par): # New York (1969), p.60 -def _constrainTriclinic(lattice): +def _constrain_triclinic(lattice): """Make constraints for Triclinic systems.""" return @@ -757,7 +757,7 @@ def _constrainCubic(lattice): # This is used to map the correct crystal system to the proper constraint # function. _constraintMap = { - "Triclinic": _constrainTriclinic, + "Triclinic": _constrain_triclinic, "Monoclinic": _constrainMonoclinic, "Orthorhombic": _constrainOrthorhombic, "Tetragonal": _constrainTetragonal, From 9f285e427a2e8bf39ef1618f1c391cecd292f1a6 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:53:02 -0500 Subject: [PATCH 42/59] _constrain_monoclinic --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 78ae9608..6b4944fd 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -640,7 +640,7 @@ def _constrain_triclinic(lattice): return -def _constrainMonoclinic(lattice): +def _constrain_monoclinic(lattice): """Make constraints for Monoclinic systems. alpha and beta are fixed to 90 unless alpha != beta and alpha == @@ -758,7 +758,7 @@ def _constrainCubic(lattice): # function. _constraintMap = { "Triclinic": _constrain_triclinic, - "Monoclinic": _constrainMonoclinic, + "Monoclinic": _constrain_monoclinic, "Orthorhombic": _constrainOrthorhombic, "Tetragonal": _constrainTetragonal, "Trigonal": _constrainTrigonal, From abce1a2f492f9c321a5cfd96012feafe06770ac5 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:53:27 -0500 Subject: [PATCH 43/59] _constrain_orthorhombic --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 6b4944fd..9ca145a2 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -661,7 +661,7 @@ def _constrain_monoclinic(lattice): return -def _constrainOrthorhombic(lattice): +def _constrain_orthorhombic(lattice): """Make constraints for Orthorhombic systems. alpha, beta and gamma are constrained to 90 @@ -759,7 +759,7 @@ def _constrainCubic(lattice): _constraintMap = { "Triclinic": _constrain_triclinic, "Monoclinic": _constrain_monoclinic, - "Orthorhombic": _constrainOrthorhombic, + "Orthorhombic": _constrain_orthorhombic, "Tetragonal": _constrainTetragonal, "Trigonal": _constrainTrigonal, "Hexagonal": _constrainHexagonal, From 75b5fea649a6b719591e5240dedd452f02e7be1e Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:53:51 -0500 Subject: [PATCH 44/59] _constrain_tetragonal --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 9ca145a2..fcfe0cc3 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -676,7 +676,7 @@ def _constrain_orthorhombic(lattice): return -def _constrainTetragonal(lattice): +def _constrain_tetragonal(lattice): """Make constraints for Tetragonal systems. b is constrained to a and alpha, beta and gamma are constrained to @@ -760,7 +760,7 @@ def _constrainCubic(lattice): "Triclinic": _constrain_triclinic, "Monoclinic": _constrain_monoclinic, "Orthorhombic": _constrain_orthorhombic, - "Tetragonal": _constrainTetragonal, + "Tetragonal": _constrain_tetragonal, "Trigonal": _constrainTrigonal, "Hexagonal": _constrainHexagonal, "Cubic": _constrainCubic, From 3ad3a6bac105a8d2c4c8799c704a6847299c8859 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:54:12 -0500 Subject: [PATCH 45/59] _constrain_trigonal --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index fcfe0cc3..3529d181 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -693,7 +693,7 @@ def _constrain_tetragonal(lattice): return -def _constrainTrigonal(lattice): +def _constrain_trigonal(lattice): """Make constraints for Trigonal systems. If gamma == 120, then b is constrained to a, alpha and beta are @@ -761,7 +761,7 @@ def _constrainCubic(lattice): "Monoclinic": _constrain_monoclinic, "Orthorhombic": _constrain_orthorhombic, "Tetragonal": _constrain_tetragonal, - "Trigonal": _constrainTrigonal, + "Trigonal": _constrain_trigonal, "Hexagonal": _constrainHexagonal, "Cubic": _constrainCubic, } From 14fea06012a1cbff9534371f891ed56538d0539e Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:54:29 -0500 Subject: [PATCH 46/59] _constrain_hexagonal --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 3529d181..a94d5e88 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -718,7 +718,7 @@ def _constrain_trigonal(lattice): return -def _constrainHexagonal(lattice): +def _constrain_hexagonal(lattice): """Make constraints for Hexagonal systems. b is constrained to a, alpha and beta are constrained to 90 and @@ -762,7 +762,7 @@ def _constrainCubic(lattice): "Orthorhombic": _constrain_orthorhombic, "Tetragonal": _constrain_tetragonal, "Trigonal": _constrain_trigonal, - "Hexagonal": _constrainHexagonal, + "Hexagonal": _constrain_hexagonal, "Cubic": _constrainCubic, } From 606728df7ea5ad4e060c63263dc7b30e294aa735 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:54:56 -0500 Subject: [PATCH 47/59] _constrain_cubic --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index a94d5e88..5781bbab 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -736,7 +736,7 @@ def _constrain_hexagonal(lattice): return -def _constrainCubic(lattice): +def _constrain_cubic(lattice): """Make constraints for Cubic systems. b and c are constrained to a, alpha, beta and gamma are constrained @@ -763,7 +763,7 @@ def _constrainCubic(lattice): "Tetragonal": _constrain_tetragonal, "Trigonal": _constrain_trigonal, "Hexagonal": _constrain_hexagonal, - "Cubic": _constrainCubic, + "Cubic": _constrain_cubic, } From 6d6048906bd672d330e1a4fbf23c8dcc10b4654c Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:55:20 -0500 Subject: [PATCH 48/59] _get_float --- src/diffpy/srfit/structure/sgconstraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 5781bbab..c9dbc5b9 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -801,7 +801,7 @@ def _makeconstraint(parname, formula, scatterer, idx, ns={}): return par # Check to see if it is a constant - fval = _getFloat(formula) + fval = _get_float(formula) if fval is not None: par.setConst() return @@ -813,7 +813,7 @@ def _makeconstraint(parname, formula, scatterer, idx, ns={}): return -def _getFloat(formula): +def _get_float(formula): """Get a float from a formula string, or None if this is not possible.""" try: return eval(formula) From c0c64181eb1611e26585eaff89680ad71e068134 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:56:31 -0500 Subject: [PATCH 49/59] _fb_remove_observer --- src/diffpy/srfit/util/observable.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/util/observable.py b/src/diffpy/srfit/util/observable.py index ff71b7d5..08f2f33b 100644 --- a/src/diffpy/srfit/util/observable.py +++ b/src/diffpy/srfit/util/observable.py @@ -52,7 +52,7 @@ def notify(self, other=()): def addObserver(self, callable): """Add callable to the set of observers.""" - f = weak_ref(callable, fallback=_fbRemoveObserver) + f = weak_ref(callable, fallback=_fb_remove_observer) self._observers.add(f) return @@ -81,7 +81,7 @@ def __init__(self, **kwds): # Local helpers -------------------------------------------------------------- -def _fbRemoveObserver(fobs, semaphores): +def _fb_remove_observer(fobs, semaphores): # Remove WeakBoundMethod `fobs` from the observers of notifying object. # This is called from Observable.notify when the WeakBoundMethod # associated object dies. From 10726188b7ff6147c1cbd44030aa713b3bc6059a Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:57:08 -0500 Subject: [PATCH 50/59] __get_object_set --- src/diffpy/srfit/util/tagmanager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/diffpy/srfit/util/tagmanager.py b/src/diffpy/srfit/util/tagmanager.py index 6e780427..9e981d64 100644 --- a/src/diffpy/srfit/util/tagmanager.py +++ b/src/diffpy/srfit/util/tagmanager.py @@ -87,7 +87,7 @@ def untag(self, obj, *tags): tags = self.tags(obj) for tag in tags: - oset = self.__getObjectSet(tag) + oset = self.__get_object_set(tag) if obj not in oset and not self.silent: raise KeyError("Tag '%s' does not apply" % tag) oset.discard(obj) @@ -107,7 +107,7 @@ def hasTags(self, obj, *tags): Returns bool """ - setgen = (self.__getObjectSet(t) for t in tags) + setgen = (self.__get_object_set(t) for t in tags) result = all(obj in s for s in setgen) return result @@ -118,7 +118,7 @@ def union(self, *tags): """ if not tags: return set() - setgen = (self.__getObjectSet(t) for t in tags) + setgen = (self.__get_object_set(t) for t in tags) objs = functools.reduce(set.union, setgen) return objs @@ -129,7 +129,7 @@ def intersection(self, *tags): """ if not tags: return set() - setgen = (self.__getObjectSet(t) for t in tags) + setgen = (self.__get_object_set(t) for t in tags) objs = functools.reduce(set.intersection, setgen) return objs @@ -145,7 +145,7 @@ def verifyTags(self, *tags): raise KeyError("Tag '%s' does not exist" % tag) return True - def __getObjectSet(self, tag): + def __get_object_set(self, tag): """Helper function for getting an object set with given tag. Raises KeyError if a passed tag does not exist and self.silent From ddb0c5e271830e31314bbb6684e07303c655b712 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 10:59:11 -0500 Subject: [PATCH 51/59] _no_observers_in_global_builders --- tests/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index b354f297..0bb50a2c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -110,7 +110,7 @@ def _makeArgs(num): @pytest.fixture(scope="session") def noObserversInGlobalBuilders(): - def _noObserversInGlobalBuilders(): + def _no_observers_in_global_builders(): """True if no observer function leaks to global builder objects. Ensure objects are not immortal due to a reference from static @@ -125,7 +125,7 @@ def _noObserversInGlobalBuilders(): break return rv - return _noObserversInGlobalBuilders() + return _no_observers_in_global_builders() @pytest.fixture(scope="session") From 74ffd56cbdb5769f29c5cba8c34df87c8652bd02 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 11:02:24 -0500 Subject: [PATCH 52/59] news --- news/rm-camelcase-privatefuncs.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/rm-camelcase-privatefuncs.rst diff --git a/news/rm-camelcase-privatefuncs.rst b/news/rm-camelcase-privatefuncs.rst new file mode 100644 index 00000000..8852c31b --- /dev/null +++ b/news/rm-camelcase-privatefuncs.rst @@ -0,0 +1,23 @@ +**Added:** + +* No news needed, changed private functions from camelcase to snakecase. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 776651a4711c424047bcdcf3538ab7b50665fc17 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 11:15:18 -0500 Subject: [PATCH 53/59] _prepare_builders --- src/diffpy/srfit/equation/builder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/equation/builder.py b/src/diffpy/srfit/equation/builder.py index cca64f6b..703a7b3f 100644 --- a/src/diffpy/srfit/equation/builder.py +++ b/src/diffpy/srfit/equation/builder.py @@ -165,7 +165,7 @@ def makeEquation( Returns a callable Literal representing the equation string. """ - self._prepareBuilders(eqstr, buildargs, argclass, argkw) + self._prepare_builders(eqstr, buildargs, argclass, argkw) beq = eval(eqstr, {}, self.builders) # handle scalar numbers or numpy arrays if isinstance(beq, (numbers.Number, numpy.ndarray)): @@ -301,7 +301,7 @@ def wipeout(self, eq): eq.setRoot(nan) return - def _prepareBuilders(self, eqstr, buildargs, argclass, argkw): + def _prepare_builders(self, eqstr, buildargs, argclass, argkw): """Prepare builders so that equation string can be evaluated. This method checks the equation string for errors and missing From 420c598168b0683f2961e9b69cdfa854f6107895 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 11:16:36 -0500 Subject: [PATCH 54/59] __eval_binary --- src/diffpy/srfit/equation/builder.py | 34 ++++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/diffpy/srfit/equation/builder.py b/src/diffpy/srfit/equation/builder.py index 703a7b3f..5422ea9f 100644 --- a/src/diffpy/srfit/equation/builder.py +++ b/src/diffpy/srfit/equation/builder.py @@ -332,7 +332,7 @@ def _prepare_builders(self, eqstr, buildargs, argclass, argkw): Returns a dictionary of the name, BaseBuilder pairs. """ - eqargs = self._getUndefinedArgs(eqstr) + eqargs = self._get_undefined_args(eqstr) # Raise an error if there are arguments that need to be created, but # this is disallowed. @@ -353,7 +353,7 @@ def _prepare_builders(self, eqstr, buildargs, argclass, argkw): return - def _getUndefinedArgs(self, eqstr): + def _get_undefined_args(self, eqstr): """Get the undefined arguments from eqstr. This tokenizes eqstr and extracts undefined arguments. An @@ -441,7 +441,7 @@ def getEquation(self): eq = Equation(name, self.literal) return eq - def __evalBinary(self, other, OperatorClass, onleft=True): + def __eval_binary(self, other, OperatorClass, onleft=True): """Evaluate a binary function. Other can be an BaseBuilder or a constant. @@ -488,28 +488,30 @@ def __evalUnary(self, OperatorClass): return opbuilder def __add__(self, other): - return self.__evalBinary(other, literals.AdditionOperator) + return self.__eval_binary(other, literals.AdditionOperator) def __radd__(self, other): - return self.__evalBinary(other, literals.AdditionOperator, False) + return self.__eval_binary(other, literals.AdditionOperator, False) def __sub__(self, other): - return self.__evalBinary(other, literals.SubtractionOperator) + return self.__eval_binary(other, literals.SubtractionOperator) def __rsub__(self, other): - return self.__evalBinary(other, literals.SubtractionOperator, False) + return self.__eval_binary(other, literals.SubtractionOperator, False) def __mul__(self, other): - return self.__evalBinary(other, literals.MultiplicationOperator) + return self.__eval_binary(other, literals.MultiplicationOperator) def __rmul__(self, other): - return self.__evalBinary(other, literals.MultiplicationOperator, False) + return self.__eval_binary( + other, literals.MultiplicationOperator, False + ) def __truediv__(self, other): - return self.__evalBinary(other, literals.DivisionOperator) + return self.__eval_binary(other, literals.DivisionOperator) def __rtruediv__(self, other): - return self.__evalBinary(other, literals.DivisionOperator, False) + return self.__eval_binary(other, literals.DivisionOperator, False) # Python 2 Compatibility ------------------------------------------------- @@ -520,16 +522,18 @@ def __rtruediv__(self, other): # ------------------------------------------------------------------------ def __pow__(self, other): - return self.__evalBinary(other, literals.ExponentiationOperator) + return self.__eval_binary(other, literals.ExponentiationOperator) def __rpow__(self, other): - return self.__evalBinary(other, literals.ExponentiationOperator, False) + return self.__eval_binary( + other, literals.ExponentiationOperator, False + ) def __mod__(self, other): - return self.__evalBinary(other, literals.RemainderOperator) + return self.__eval_binary(other, literals.RemainderOperator) def __rmod__(self, other): - return self.__evalBinary(other, literals.RemainderOperator, False) + return self.__eval_binary(other, literals.RemainderOperator, False) def __neg__(self): return self.__evalUnary(literals.NegationOperator) From 8e838f3d26635307c257066680680a5282d25ec3 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 11:16:49 -0500 Subject: [PATCH 55/59] __eval_unary --- src/diffpy/srfit/equation/builder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/equation/builder.py b/src/diffpy/srfit/equation/builder.py index 5422ea9f..4248f1fd 100644 --- a/src/diffpy/srfit/equation/builder.py +++ b/src/diffpy/srfit/equation/builder.py @@ -479,7 +479,7 @@ def __eval_binary(self, other, OperatorClass, onleft=True): opbuilder.literal = op return opbuilder - def __evalUnary(self, OperatorClass): + def __eval_unary(self, OperatorClass): """Evaluate a unary function.""" op = OperatorClass() op.addLiteral(self.literal) @@ -536,7 +536,7 @@ def __rmod__(self, other): return self.__eval_binary(other, literals.RemainderOperator, False) def __neg__(self): - return self.__evalUnary(literals.NegationOperator) + return self.__eval_unary(literals.NegationOperator) # These are used by the class. From 2973a2caab73022a560d48f7b253aa193814f3a5 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 11:17:50 -0500 Subject: [PATCH 56/59] __wrap_srfit_operators --- src/diffpy/srfit/equation/builder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/diffpy/srfit/equation/builder.py b/src/diffpy/srfit/equation/builder.py index 4248f1fd..4485087f 100644 --- a/src/diffpy/srfit/equation/builder.py +++ b/src/diffpy/srfit/equation/builder.py @@ -710,7 +710,7 @@ def getBuilder(name): return _builders[name] -def __wrapNumpyOperators(): +def __wrap_numpy_operators(): """Export all numpy operators as OperatorBuilder instances in the module namespace.""" for name in dir(numpy): @@ -720,11 +720,11 @@ def __wrapNumpyOperators(): return -__wrapNumpyOperators() +__wrap_numpy_operators() # Register other functions as well -def __wrapSrFitOperators(): +def __wrap_srfit_operators(): """Export all non-base operators from the diffpy.srfit.equation.literals.operators module as OperatorBuilder instances in the module namespace.""" @@ -748,6 +748,6 @@ def _is_exported_type(cls): return -__wrapSrFitOperators() +__wrap_srfit_operators() # End of file From 0843fd703374691d3f43023fc8de47a1cc2fb5c6 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 11:18:58 -0500 Subject: [PATCH 57/59] _get_args --- src/diffpy/srfit/equation/equationmod.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/equation/equationmod.py b/src/diffpy/srfit/equation/equationmod.py index aab8d99f..dd8293ec 100644 --- a/src/diffpy/srfit/equation/equationmod.py +++ b/src/diffpy/srfit/equation/equationmod.py @@ -125,10 +125,10 @@ def operation(self, *args, **kw): """ return self.__call__(*args, **kw) - def _getArgs(self): + def _get_args(self): return list(self.argdict.values()) - args = property(_getArgs) + args = property(_get_args) def __getattr__(self, name): """Gives access to the Arguments as attributes.""" From f45e2ed7588d238dcf42a5a8cc1b460b1a26d642 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 11:20:15 -0500 Subject: [PATCH 58/59] _loop_check --- src/diffpy/srfit/equation/literals/operators.py | 6 +++--- src/diffpy/srfit/equation/visitors/swapper.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/diffpy/srfit/equation/literals/operators.py b/src/diffpy/srfit/equation/literals/operators.py index 98264bec..a7863808 100644 --- a/src/diffpy/srfit/equation/literals/operators.py +++ b/src/diffpy/srfit/equation/literals/operators.py @@ -113,7 +113,7 @@ def addLiteral(self, literal): Raises ValueError if the literal causes a self-reference. """ # Make sure we don't have self-reference - self._loopCheck(literal) + self._loop_check(literal) self.args.append(literal) literal.addObserver(self._flush) self._flush(other=(self,)) @@ -128,7 +128,7 @@ def getValue(self): value = property(lambda self: self.getValue()) - def _loopCheck(self, literal): + def _loop_check(self, literal): """Check if a literal causes self-reference.""" if literal is self: raise ValueError("'%s' causes self-reference" % literal) @@ -136,7 +136,7 @@ def _loopCheck(self, literal): # Check to see if I am a dependency of the literal. if hasattr(literal, "args"): for lit_arg in literal.args: - self._loopCheck(lit_arg) + self._loop_check(lit_arg) return diff --git a/src/diffpy/srfit/equation/visitors/swapper.py b/src/diffpy/srfit/equation/visitors/swapper.py index b5ddbf4d..a6135750 100644 --- a/src/diffpy/srfit/equation/visitors/swapper.py +++ b/src/diffpy/srfit/equation/visitors/swapper.py @@ -105,7 +105,7 @@ def onOperator(self, op): # Validate the new literal. If it fails, we need to restore the # old one try: - op._loopCheck(newlit) + op._loop_check(newlit) except ValueError: # Restore the old literal op.args.insert(idx, oldlit) @@ -135,9 +135,9 @@ def onEquation(self, eq): eq.setRoot(self.newlit) return - # Now move into the equation. We have to do a _loopCheck to make sure + # Now move into the equation. We have to do a _loop_check to make sure # that we won't have any loops in the equation. - eq._loopCheck(self.newlit) + eq._loop_check(self.newlit) eq.root.identify(self) # Reset the root in case anything changed underneath. From 32d69ab0ee6bb8455af5112aa23064e90860091b Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Wed, 10 Dec 2025 11:21:30 -0500 Subject: [PATCH 59/59] _on_infix --- src/diffpy/srfit/equation/visitors/printer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diffpy/srfit/equation/visitors/printer.py b/src/diffpy/srfit/equation/visitors/printer.py index 4926c9ae..98cfab6a 100644 --- a/src/diffpy/srfit/equation/visitors/printer.py +++ b/src/diffpy/srfit/equation/visitors/printer.py @@ -87,7 +87,7 @@ def onOperator(self, op): """Process an Operator node.""" # We have to deal with infix operators if op.name != op.symbol and op.nin == 2: - self._onInfix(op) + self._on_infix(op) return self.output self.output += str(op.name) + "(" @@ -111,7 +111,7 @@ def onEquation(self, eq): eq.root.identify(self) return self.output - def _onInfix(self, op): + def _on_infix(self, op): """Process infix operators.""" self.output += "(" op.args[0].identify(self)