Skip to content

Lint Check #23

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
lint check for flake8 issue
  • Loading branch information
stevenhua0320 committed Jul 29, 2024
commit b3bb7c6e338385a76703ef51eb43fd6d3a0c2529
4 changes: 2 additions & 2 deletions devutils/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def rm(directory, filerestr):
rm("../doc/examples/output", r"known_dG.*\.pwa")
rm("../doc/examples/output", r"unknown_dG.*\.pwa")

### Testing examples
# Testing examples
examples = Test()
test_names = [
"extract_single_peak",
Expand All @@ -110,7 +110,7 @@ def rm(directory, filerestr):

examples.report()

### Convert output of example files to Unix-style endlines for sdist.
# Convert output of example files to Unix-style endlines for sdist.
if os.linesep != "\n":
print("==== Scrubbing Endlines ====")
# All *.srmise and *.pwa files in examples directory.
Expand Down
16 changes: 8 additions & 8 deletions diffpy/srmise/basefunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __init__(
emsg = "Argument default_formats must specify 'default_input' " + "and 'default_output' as keys."
raise ValueError(emsg)
for f in self.default_formats.values():
if not f in self.parformats:
if f not in self.parformats:
emsg = "Keys of argument default_formats must map to a " + "value within argument parformats."
raise ValueError()

Expand All @@ -140,7 +140,7 @@ def __init__(
pass
return

#### "Virtual" class methods ####
# "Virtual" class methods ####

def actualize(self, *args, **kwds):
"""Create ModelPart instance of self with given parameters. ("Virtual" method)"""
Expand Down Expand Up @@ -172,7 +172,7 @@ def _valueraw(self, *args, **kwds):
emsg = "_valueraw must() be implemented in a BaseFunction subclass."
raise NotImplementedError(emsg)

#### Class methods ####
# Class methods ####

def jacobian(self, p, r, rng=None):
"""Calculate jacobian of p, possibly restricted by range.
Expand Down Expand Up @@ -228,9 +228,9 @@ def transform_derivatives(self, pars, in_format=None, out_format=None):
elif out_format == "default_input":
out_format = self.default_formats["default_input"]

if not in_format in self.parformats:
if in_format not in self.parformats:
raise ValueError("Argument 'in_format' must be one of %s." % self.parformats)
if not out_format in self.parformats:
if out_format not in self.parformats:
raise ValueError("Argument 'out_format' must be one of %s." % self.parformats)
if in_format == out_format:
return np.identity(self.npars)
Expand Down Expand Up @@ -263,9 +263,9 @@ def transform_parameters(self, pars, in_format=None, out_format=None):
elif out_format == "default_input":
out_format = self.default_formats["default_input"]

if not in_format in self.parformats:
if in_format not in self.parformats:
raise ValueError("Argument 'in_format' must be one of %s." % self.parformats)
if not out_format in self.parformats:
if out_format not in self.parformats:
raise ValueError("Argument 'out_format' must be one of %s." % self.parformats)
# if in_format == out_format:
# return pars
Expand Down Expand Up @@ -335,7 +335,7 @@ def writestr(self, baselist):
"""
if self.base is not None and self.base not in baselist:
emsg = "baselist does not include this BaseFunction's base function."
raise ValueError("emsg")
raise ValueError(emsg)
lines = []
# Write function type
lines.append("function=%s" % repr(self.__class__.__name__))
Expand Down
28 changes: 14 additions & 14 deletions diffpy/srmise/multimodelselection.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,41 +529,41 @@ def plot3dclassprobs(self, **kwds):

### Define face colors
fc = np.array([len(self.classes[z]) for z in zlabels])
if class_size is "fraction":
if class_size == "fraction":
fc = fc / float(len(self.results))

# Index the colormap if necessary
if class_size is "number":
if norm is "auto":
if class_size == "number":
if norm == "auto":
indexedcolors = cmap(np.linspace(0.0, 1.0, np.max(fc)))
cmap = colors.ListedColormap(indexedcolors)
elif norm is "full":
elif norm == "full":
indexedcolors = cmap(np.linspace(0.0, 1.0, len(self.results)))
cmap = colors.ListedColormap(indexedcolors)
# A user-specified norm cannot be used to index a colormap.

# Create proper norms for "auto" and "full" types.
if norm is "auto":
if class_size is "number":
if norm == "auto":
if class_size == "number":
mic = np.min(fc)
mac = np.max(fc)
nc = mac - mic + 1
norm = colors.BoundaryNorm(np.linspace(mic, mac + 1, nc + 1), nc)
if class_size is "fraction":
if class_size == "fraction":
norm = colors.Normalize()
norm.autoscale(fc)
elif norm is "full":
elif norm == "full":
mcolor = len(self.results)
if class_size is "number":
if class_size == "number":
norm = colors.BoundaryNorm(np.linspace(0, mcolor + 1, mcolor + 2), mcolor + 1)
if class_size is "fraction":
if class_size == "fraction":
norm = colors.Normalize(0.0, 1.0)

zs = np.arange(len(zlabels))

poly = PolyCollection(verts, facecolors=cmap(norm(fc)), closed=False)
poly.set_alpha(p_alpha)
cax = ax.add_collection3d(poly, zs=zs, zdir="y")
ax.add_collection3d(poly, zs=zs, zdir="y")

# Highlight values of interest
color_idx = np.linspace(0, 1, len(highlight))
Expand Down Expand Up @@ -601,7 +601,7 @@ def plot3dclassprobs(self, **kwds):
)

if title is not False:
figtitle = fig.suptitle(title)
fig.suptitle(title)

# Add colorbar
if "cbpos" in kwds:
Expand All @@ -625,9 +625,9 @@ def plot3dclassprobs(self, **kwds):

cb = colorbar.ColorbarBase(cbaxis, cmap=cmap, norm=norm, **kwds)

if class_size is "number":
if class_size == "number":
cb.set_label("Models in class")
elif class_size is "fraction":
elif class_size == "fraction":
cb.set_label("Fraction of models in class")

return {"fig": fig, "axis": ax, "cb": cb, "cbaxis": cbaxis}
Expand Down
Loading