Skip to content

Commit

Permalink
E721
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-rakowski committed Nov 10, 2023
1 parent dfa7546 commit 79b2559
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion py4DSTEM/datacube/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def get_probe_size(
"dp_mean" in self.treekeys
), "calculate .get_dp_mean() or pass a `dp` arg"
DP = self.tree("dp_mean").data
elif type(dp) == str:
elif isinstance(dp, str):
assert dp in self.treekeys, f"mode {dp} not found in the tree"
DP = self.tree(dp)
elif type(dp) == np.ndarray:
Expand Down
6 changes: 3 additions & 3 deletions py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def R_pixel_size(self):

@R_pixel_size.setter
def R_pixel_size(self, x):
if type(x) is not list:
if not isinstance(x, list):
x = [x, x]
self.set_dim(0, [0, x[0]])
self.set_dim(1, [0, x[1]])
Expand All @@ -120,7 +120,7 @@ def R_pixel_units(self):

@R_pixel_units.setter
def R_pixel_units(self, x):
if type(x) is not list:
if not isinstance(x, list):
x = [x, x]
self.dim_units[0] = x[0]
self.dim_units[1] = x[1]
Expand All @@ -133,7 +133,7 @@ def Q_pixel_size(self):

@Q_pixel_size.setter
def Q_pixel_size(self, x):
if type(x) is not list:
if not isinstance(x, list):
x = [x, x]
self.set_dim(2, [0, x[0]])
self.set_dim(3, [0, x[1]])
Expand Down
12 changes: 9 additions & 3 deletions py4DSTEM/preprocess/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ def bin_data_diffraction(datacube, bin_factor, dtype=None):
"""
# validate inputs
assert type(bin_factor) is int, f"Error: binning factor {bin_factor} is not an int."
assert isinstance(
bin_factor, int
), f"Error: binning factor {bin_factor} is not an int."
if bin_factor == 1:
return datacube
if dtype is None:
Expand Down Expand Up @@ -225,7 +227,9 @@ def bin_data_mmap(datacube, bin_factor, dtype=np.float32):
"""
# validate inputs
assert type(bin_factor) is int, f"Error: binning factor {bin_factor} is not an int."
assert isinstance(
bin_factor, int
), f"Error: binning factor {bin_factor} is not an int."
if bin_factor == 1:
return datacube

Expand Down Expand Up @@ -268,7 +272,9 @@ def bin_data_real(datacube, bin_factor):
Performs diffraction space binning of data by bin_factor.
"""
# validate inputs
assert type(bin_factor) is int, f"Bin factor {bin_factor} is not an int."
assert isinstance(
bin_factor, int
), f"Error: binning factor {bin_factor} is not an int."
if bin_factor <= 1:
return datacube

Expand Down
4 changes: 3 additions & 1 deletion py4DSTEM/process/diffraction/tdesign.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def tdesign(degree):

assert degree <= 21, "Degree must be 21 or less."
assert degree >= 1, "Degree should be at least 1."
assert type(degree) is int, "Degree should be an integer."
assert isinstance(
degree, int
), f"Degree should be an integer, {type(degree)} passed."

vecs = _tdesigns[degree - 1]

Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/visualize/vis_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def show_image_grid(
)
except IndexError:
ax.axis("off")
if type(title) == str:
if isinstance(title, str):
fig.suptitle(title)
if suptitle:
fig.suptitle(suptitle)
Expand Down

0 comments on commit 79b2559

Please sign in to comment.