Skip to content

Fix flake8 error of unambiguous variable names and "not xxx in" expression (E741, E713) #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 21, 2024
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
10 changes: 5 additions & 5 deletions doc/examples/npintensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,15 @@ def plotResults(recipe):
# All this should be pretty familiar by now.
q = recipe.bucky.profile.x

I = recipe.bucky.profile.y
Icalc = recipe.bucky.profile.ycalc
intensity = recipe.bucky.profile.y
intensity_calc = recipe.bucky.profile.ycalc
bkgd = recipe.bucky.evaluateEquation("bkgd")
diff = I - Icalc
diff = intensity - intensity_calc

import pylab

pylab.plot(q, I, "ob", label="I(Q) Data")
pylab.plot(q, Icalc, "r-", label="I(Q) Fit")
pylab.plot(q, intensity, "ob", label="I(Q) Data")
pylab.plot(q, intensity_calc, "r-", label="I(Q) Fit")
pylab.plot(q, diff, "g-", label="I(Q) diff")
pylab.plot(q, bkgd, "c-", label="Bkgd. Fit")
pylab.xlabel(r"$Q (\AA^{-1})$")
Expand Down
10 changes: 6 additions & 4 deletions src/diffpy/srfit/equation/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,11 @@ def _getUndefinedArgs(self, eqstr):
# generated.
for tok in set(args):
# Move genuine varibles to the eqargs dictionary
if (tok in self.builders or # Check registered builders
tok in EquationFactory.symbols or # Check symbols
tok in EquationFactory.ignore): # Check ignored characters
if (
tok in self.builders # Check registered builders
or tok in EquationFactory.symbols # Check symbols
or tok in EquationFactory.ignore # Check ignored characters
):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done automatically by black .

args.remove(tok)

return args
Expand Down Expand Up @@ -665,7 +667,7 @@ def __wrapSrFitOperators():
inspect.isclass(cls)
and issubclass(cls, opmod.Operator)
and not inspect.isabstract(cls)
and not cls in excluded_types
and cls not in excluded_types
)
# create OperatorBuilder objects
for nm, opclass in inspect.getmembers(opmod, is_exported_type):
Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/srfit/equation/equationmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __getattr__(self, name):
"""Gives access to the Arguments as attributes."""
# Avoid infinite loop on argdict lookup.
argdict = object.__getattribute__(self, "argdict")
if not name in argdict:
if name not in argdict:
raise AttributeError("No argument named '%s' here" % name)
return argdict[name]

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 @@ -123,7 +123,7 @@ def addLiteral(self, literal):
def getValue(self):
"""Get or evaluate the value of the operator."""
if self._value is None:
vals = [l.value for l in self.args]
vals = [arg.value for arg in self.args]
self._value = self.operation(*vals)
return self._value

Expand All @@ -136,8 +136,8 @@ def _loopCheck(self, literal):

# Check to see if I am a dependency of the literal.
if hasattr(literal, "args"):
for l in literal.args:
self._loopCheck(l)
for arg in literal.args:
self._loopCheck(arg)
return


Expand Down
2 changes: 1 addition & 1 deletion src/diffpy/srfit/fitbase/fitresults.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def formatResults(self, header="", footer="", update=False):

if not certain:
error_message = "Some quantities invalid due to missing profile uncertainty"
if not error_message in self.messages:
if error_message not in self.messages:
self.messages.append(error_message)

lines.extend(self.messages)
Expand Down
1 change: 0 additions & 1 deletion src/diffpy/srfit/util/argbinders.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class bind2nd(object):

"""Freeze second argument of a callable object to a given constant."""

def __init__(self, func, arg1):
Expand Down