Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions src/diffpy/srfit/fitbase/fithook.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ def postcall(self, recipe, chiv):
print("Variables")
vnames = recipe.getNames()
vals = recipe.getValues()
byname = lambda nv: sortKeyForNumericString(nv[0])
items = sorted(zip(vnames, vals), key=byname)
items = sorted(zip(vnames, vals), key=lambda nv: sortKeyForNumericString(nv[0]))
for name, val in items:
print(" %s = %f" % (name, val))
return
Expand Down
12 changes: 4 additions & 8 deletions src/diffpy/srfit/fitbase/recipeorganizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,7 @@ def clearConstraints(self, recurse=False):
self.unconstrain(*self._constraints)

if recurse:
f = lambda m: hasattr(m, "clearConstraints")
for m in filter(f, self._iterManaged()):
for m in filter(lambda m: hasattr(m, "clearConstraints"), self._iterManaged()):
m.clearConstraints(recurse)
return

Expand Down Expand Up @@ -813,17 +812,15 @@ def clearRestraints(self, recurse=False):
self.unrestrain(*self._restraints)

if recurse:
f = lambda m: hasattr(m, "clearRestraints")
for m in filter(f, self._iterManaged()):
for m in filter(lambda m: hasattr(m, "clearRestraints"), self._iterManaged()):
m.clearRestraints(recurse)
return

def _getConstraints(self, recurse=True):
"""Get the constrained Parameters for this and managed sub-objects."""
constraints = {}
if recurse:
f = lambda m: hasattr(m, "_getConstraints")
for m in filter(f, self._iterManaged()):
for m in filter(lambda m: hasattr(m, "_getConstraints"), self._iterManaged()):
constraints.update(m._getConstraints(recurse))

constraints.update(self._constraints)
Expand All @@ -837,8 +834,7 @@ def _getRestraints(self, recurse=True):
"""
restraints = set(self._restraints)
if recurse:
f = lambda m: hasattr(m, "_getRestraints")
for m in filter(f, self._iterManaged()):
for m in filter(lambda m: hasattr(m, "_getRestraints"), self._iterManaged()):
restraints.update(m._getRestraints(recurse))

return restraints
Expand Down
6 changes: 3 additions & 3 deletions src/diffpy/srfit/tests/testbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def testParseEquation(self):
eq.x.setValue(x)
eq.B.setValue(B)
eq.C.setValue(C)
f = lambda A, x, B, C: A * sin(0.5 * x) + divide(B, C)
f = lambda A, x, B, C: A * sin(0.5 * x) + divide(B, C) # noqa: E731
self.assertTrue(array_equal(eq(), f(A, x, B, C)))

# Make sure that the arguments of eq are listed in the order in which
Expand All @@ -170,7 +170,7 @@ def testParseEquation(self):
sigma = 0.1
eq.x.setValue(x)
eq.sigma.setValue(sigma)
f = lambda x, sigma: sqrt(e ** (-0.5 * (x / sigma) ** 2))
f = lambda x, sigma: sqrt(e ** (-0.5 * (x / sigma) ** 2)) # noqa: E731
self.assertTrue(numpy.allclose(eq(), f(x, sigma)))

self.assertEqual(eq.args, [eq.x, eq.sigma])
Expand Down Expand Up @@ -246,7 +246,7 @@ def _f(a, b):
sigma = builder.ArgumentBuilder(name="sigma", value=0.1)
beq = sqrt(e ** (-0.5 * (x / sigma) ** 2))
eq = beq.getEquation()
f = lambda x, sigma: sqrt(e ** (-0.5 * (x / sigma) ** 2))
f = lambda x, sigma: sqrt(e ** (-0.5 * (x / sigma) ** 2)) # noqa: E731
self.assertTrue(numpy.allclose(eq(), numpy.sqrt(e ** (-0.5 * (_x / 0.1) ** 2))))

# Equation with Equation
Expand Down