Skip to content

Commit

Permalink
Merge pull request #569 from alex-rakowski/more_fixes
Browse files Browse the repository at this point in the history
righting my wrongs
  • Loading branch information
sezelt authored Nov 19, 2023
2 parents 40ae3cb + 683d7c3 commit 158f280
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion py4DSTEM/braggvectors/diskdetection_aiml_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def get_maxima_2D_cp(
if minSpacing > 0:
deletemask = np.zeros(len(maxima), dtype=bool)
for i in range(len(maxima)):
if deletemask[i] is False:
if deletemask[i] == False: # noqa: E712
tooClose = (
(maxima["x"] - maxima["x"][i]) ** 2
+ (maxima["y"] - maxima["y"][i]) ** 2
Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/braggvectors/diskdetection_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def get_maxima_2D(
if minSpacing > 0:
deletemask = np.zeros(len(maxima), dtype=bool)
for i in range(len(maxima)):
if deletemask[i] is False:
if deletemask[i] == False: # noqa: E712
tooClose = (
(maxima["x"] - maxima["x"][i]) ** 2
+ (maxima["y"] - maxima["y"][i]) ** 2
Expand Down
5 changes: 2 additions & 3 deletions py4DSTEM/braggvectors/threshold.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Bragg peaks thresholding fns

import numpy as np

from emdfile import tqdmnd, PointListArray


Expand Down Expand Up @@ -52,7 +51,7 @@ def threshold_Braggpeaks(
r2 = minPeakSpacing**2
deletemask = np.zeros(pointlist.length, dtype=bool)
for i in range(pointlist.length):
if deletemask[i] is False:
if deletemask[i] == False: # noqa: E712
tooClose = (
(pointlist.data["qx"] - pointlist.data["qx"][i]) ** 2
+ (pointlist.data["qy"] - pointlist.data["qy"][i]) ** 2
Expand Down Expand Up @@ -160,7 +159,7 @@ def universal_threshold(
r2 = minPeakSpacing**2
deletemask = np.zeros(pointlist.length, dtype=bool)
for i in range(pointlist.length):
if deletemask[i] is False:
if deletemask[i] == False: # noqa: E712
tooClose = (
(pointlist.data["qx"] - pointlist.data["qx"][i]) ** 2
+ (pointlist.data["qy"] - pointlist.data["qy"][i]) ** 2
Expand Down
14 changes: 7 additions & 7 deletions py4DSTEM/io/filereaders/read_K2.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ def _find_offsets(self):
for i in range(8):
sync = False
frame = 0
while sync is False:
while sync == False: # noqa: E712
sync = self._bin_files[i][frame]["block"] == block_id
if sync is False:
if sync == False: # noqa: E712
frame += 1
self._shutter_offsets[i] += frame
print("Offsets are currently ", self._shutter_offsets)
Expand All @@ -358,20 +358,20 @@ def _find_offsets(self):
sync = False
next_frame = stripe[j]["frame"]

if sync is False:
if sync == False: # noqa: E712
# the first frame is incomplete, so we need to seek the next one
print(
f"First frame ({first_frame}) incomplete, seeking frame {next_frame}..."
)
for i in range(8):
sync = False
frame = 0
while sync is False:
while sync == False: # noqa: E712
sync = (
self._bin_files[i][self._shutter_offsets[i] + frame]["frame"]
== next_frame
)
if sync is False:
if sync == False: # noqa: E712
frame += 1
self._shutter_offsets[i] += frame
print("Offsets are now ", self._shutter_offsets)
Expand All @@ -387,7 +387,7 @@ def _find_offsets(self):
]
if np.any(stripe[:]["frame"] != first_frame):
sync = False
if sync is True:
if sync == True: # noqa: E712
print("New frame is complete!")
else:
print("Next frame also incomplete!!!! Data may be corrupt?")
Expand All @@ -397,7 +397,7 @@ def _find_offsets(self):
for i in range(8):
shutter = False
frame = 0
while shutter is False:
while shutter == False: # noqa: E712
offset = self._shutter_offsets[i] + (frame * 32)
stripe = self._bin_files[i][offset : offset + 32]
shutter = stripe[0]["shutter"]
Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/preprocess/radialbkgrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_1D_polar_background(
# Crop polar data to maximum distance which contains information from original image
if (polarData.mask.sum(axis=(0)) == polarData.shape[0]).any():
ii = polarData.data.shape[1] - 1
while polarData.mask[:, ii].all() is True:
while polarData.mask[:, ii].all() == True: # noqa: E712
ii = ii - 1
maximalDistance = ii
polarData = polarData[:, 0:maximalDistance]
Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/preprocess/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def filter_2D_maxima(
if minSpacing > 0:
deletemask = np.zeros(len(maxima), dtype=bool)
for i in range(len(maxima)):
if deletemask[i] == False:
if deletemask[i] == False: # noqa: E712
tooClose = (
(maxima["x"] - maxima["x"][i]) ** 2
+ (maxima["y"] - maxima["y"][i]) ** 2
Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/process/calibration/ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def fit_ellipse_1D(ar, center=None, fitradii=None, mask=None):
rr = np.sqrt((xx - x0) ** 2 + (yy - y0) ** 2)
_mask = (rr > ri) * (rr <= ro)
if mask is not None:
_mask *= mask is False
_mask *= mask == False # noqa: E712
xs, ys = np.nonzero(_mask)
vals = ar[_mask]

Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/process/calibration/qpixelsize.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def get_dq_from_indexed_peaks(qs, hkl, a):
# Get pixel size
dq = 1 / (c * a)
qs_fit = d_inv[mask] / a
hkl_fit = [hkl[i] for i in range(len(hkl)) if mask[i] is True]
hkl_fit = [hkl[i] for i in range(len(hkl)) if mask[i] == True] # noqa: E712

return dq, qs_fit, hkl_fit
4 changes: 2 additions & 2 deletions py4DSTEM/process/classification/braggvectorclassification.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ def merge_iterative(self, threshBPs=0.1, threshScanPosition=0.1):
W_merge = W_merge[:, 1:]
H_merge = H_merge[1:, :]

W_ = np.hstack((W_[:, merged is False], W_merge))
H_ = np.vstack((H_[merged is False, :], H_merge))
W_ = np.hstack((W_[:, merged == False], W_merge)) # noqa: E712
H_ = np.vstack((H_[merged == False, :], H_merge)) # noqa: E712
Nc_ = W_.shape[1]

if len(merge_candidates) == 0:
Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/process/classification/featurization.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def from_braggvectors(
(pointlist.data["qy"] / q_pixel_size) + Q_Ny / 2
).astype(int),
]
is False
== False # noqa: E712
),
True,
False,
Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/process/diffraction/crystal_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def quantify_phase_pointlist(
if len(pointlist["qx"]) > 0:
if mask_peaks is not None:
for i in range(len(mask_peaks)):
if mask_peaks[i] is None:
if mask_peaks[i] == None: # noqa: E711
continue
inds_mask = np.where(
pointlist_peak_intensity_matches[:, mask_peaks[i]] != 0
Expand Down

0 comments on commit 158f280

Please sign in to comment.