Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
4f247d6
_update_configuration
cadenmyers13 Dec 10, 2025
3ea20f0
_store_configurable
cadenmyers13 Dec 10, 2025
e664263
__verify_profiles and __collect_constraints_and_restraints
cadenmyers13 Dec 10, 2025
b4d1142
_new_parameter
cadenmyers13 Dec 10, 2025
faf2edb
__get_var_and_check
cadenmyers13 Dec 10, 2025
bed70e7
__get_vars_from_args
cadenmyers13 Dec 10, 2025
002b4b3
_apply_values
cadenmyers13 Dec 10, 2025
820a6ff
_calculate_covariance
cadenmyers13 Dec 10, 2025
0a8ec03
_calculate_jacobian
cadenmyers13 Dec 10, 2025
534c100
_calculate_metrics
cadenmyers13 Dec 10, 2025
ba6202b
_calculate_constraint_uncertainties
cadenmyers13 Dec 10, 2025
8a1b4ea
_iter_managed
cadenmyers13 Dec 10, 2025
e3d6773
_add_object
cadenmyers13 Dec 10, 2025
d707900
_remove_object
cadenmyers13 Dec 10, 2025
0194888
_locate_managed_object
cadenmyers13 Dec 10, 2025
c430287
_add_parameter
cadenmyers13 Dec 10, 2025
df66346
_remove_parameter
cadenmyers13 Dec 10, 2025
d3cb4c9
_get_constraints
cadenmyers13 Dec 10, 2025
60d8322
_get_restraints
cadenmyers13 Dec 10, 2025
ba289fc
_format_constraints
cadenmyers13 Dec 10, 2025
06a37eb
_format_restraints
cadenmyers13 Dec 10, 2025
2b62174
_validate_others
cadenmyers13 Dec 10, 2025
e72e704
_set_calculator
cadenmyers13 Dec 10, 2025
8b7de3e
_setup_generator
cadenmyers13 Dec 10, 2025
67834ea
_get_meta_value
cadenmyers13 Dec 10, 2025
c92e179
_getelem
cadenmyers13 Dec 10, 2025
98bfed3
_setelem
cadenmyers13 Dec 10, 2025
b3850c3
_get_srreal_structure
cadenmyers13 Dec 10, 2025
9ad376a
_constrain_space_group
cadenmyers13 Dec 10, 2025
26cd321
_create_space_group
cadenmyers13 Dec 10, 2025
dcdb243
_constrain_as_space_group
cadenmyers13 Dec 10, 2025
a5c9d8c
_get_lat_pars
cadenmyers13 Dec 10, 2025
7bad1de
_get_xyz_pars
cadenmyers13 Dec 10, 2025
7393f08
_get_adp_pars
cadenmyers13 Dec 10, 2025
730b841
_make_constraints
cadenmyers13 Dec 10, 2025
44a35d6
_clear_constraints
cadenmyers13 Dec 10, 2025
8c94299
_constrain_lattice
cadenmyers13 Dec 10, 2025
6bd9bfd
_constrain_xyzs
cadenmyers13 Dec 10, 2025
70d701c
_constrain_adps
cadenmyers13 Dec 10, 2025
20e048a
__add_par
cadenmyers13 Dec 10, 2025
aca79b1
_constrain_triclinic
cadenmyers13 Dec 10, 2025
9f285e4
_constrain_monoclinic
cadenmyers13 Dec 10, 2025
abce1a2
_constrain_orthorhombic
cadenmyers13 Dec 10, 2025
75b5fea
_constrain_tetragonal
cadenmyers13 Dec 10, 2025
3ad3a6b
_constrain_trigonal
cadenmyers13 Dec 10, 2025
14fea06
_constrain_hexagonal
cadenmyers13 Dec 10, 2025
606728d
_constrain_cubic
cadenmyers13 Dec 10, 2025
6d60489
_get_float
cadenmyers13 Dec 10, 2025
c0c6418
_fb_remove_observer
cadenmyers13 Dec 10, 2025
1072618
__get_object_set
cadenmyers13 Dec 10, 2025
ddb0c5e
_no_observers_in_global_builders
cadenmyers13 Dec 10, 2025
74ffd56
news
cadenmyers13 Dec 10, 2025
776651a
_prepare_builders
cadenmyers13 Dec 10, 2025
420c598
__eval_binary
cadenmyers13 Dec 10, 2025
8e838f3
__eval_unary
cadenmyers13 Dec 10, 2025
2973a2c
__wrap_srfit_operators
cadenmyers13 Dec 10, 2025
0843fd7
_get_args
cadenmyers13 Dec 10, 2025
f45e2ed
_loop_check
cadenmyers13 Dec 10, 2025
32d69ab
_on_infix
cadenmyers13 Dec 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/examples/gaussiangenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/source/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 23 additions & 0 deletions news/rm-camelcase-privatefuncs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* No news needed, changed private functions from camelcase to snakecase.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
50 changes: 27 additions & 23 deletions src/diffpy/srfit/equation/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -332,7 +332,7 @@ def _prepareBuilders(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.
Expand All @@ -353,7 +353,7 @@ def _prepareBuilders(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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -479,7 +479,7 @@ def __evalBinary(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)
Expand All @@ -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 -------------------------------------------------

Expand All @@ -520,19 +522,21 @@ 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)
return self.__eval_unary(literals.NegationOperator)


# These are used by the class.
Expand Down Expand Up @@ -706,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):
Expand All @@ -716,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."""
Expand All @@ -744,6 +748,6 @@ def _is_exported_type(cls):
return


__wrapSrFitOperators()
__wrap_srfit_operators()

# End of file
4 changes: 2 additions & 2 deletions src/diffpy/srfit/equation/equationmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
6 changes: 3 additions & 3 deletions src/diffpy/srfit/equation/literals/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,))
Expand All @@ -128,15 +128,15 @@ 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)

# 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


Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/srfit/equation/visitors/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) + "("
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/diffpy/srfit/equation/visitors/swapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/diffpy/srfit/fitbase/configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ 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):
def _store_configurable(self, obj):
"""Store a Configurable.

The passed obj is only stored if it is a a Configurable,
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/srfit/fitbase/fitcontribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
Loading
Loading