Skip to content

Commit

Permalink
correcting multiple exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-rakowski authored Nov 9, 2023
1 parent 53e8796 commit fbbc232
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 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 @@ -638,7 +638,7 @@ def upsampled_correlation_cp(imageCorr, upsampleFactor, xyShift):
dx = (icc[2, 1] - icc[0, 1]) / (4 * icc[1, 1] - 2 * icc[2, 1] - 2 * icc[0, 1])
dy = (icc[1, 2] - icc[1, 0]) / (4 * icc[1, 1] - 2 * icc[1, 2] - 2 * icc[1, 0])
# TODO I think this is just the Index Error
except IndexError or Exception:
except (IndexError, Exception):
dx, dy = (
0,
0,
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 @@ -619,7 +619,7 @@ def upsampled_correlation(imageCorr, upsampleFactor, xyShift):
4 * icc[1, 1] - 2 * icc[1, 2] - 2 * icc[1, 0]
)
# TODO Work out what exception to use
except IndexError or Exception:
except (IndexError, Exception):
dx, dy = (
0,
0,
Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/datacube/virtualimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def position_detector(
image = self.tree(k)
break
# TODO check what error is produced when passing nonexistant key to tree
except KeyError or AttributeError:
except (KeyError, AttributeError):
pass
if image is None:
image = self[0, 0]
Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/io/legacy/read_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def get_N_dataobjects(filepath, topgroup="4DSTEM_experiment"):
try:
N_coords = len(f[topgroup]["data/coordinates"].keys())
# TODO work out what exception will be raised
except ValueError or AttributeError or Exception:
except (ValueError, AttributeError, Exception):
N_coords = 0
N_do = N_dc + N_cdc + N_ds + N_rs + N_pl + N_pla + N_coords
return N_dc, N_cdc, N_ds, N_rs, N_pl, N_pla, N_coords, N_do
2 changes: 1 addition & 1 deletion py4DSTEM/process/utils/multicorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def upsampled_correlation(imageCorr, upsampleFactor, xyShift, device="cpu"):
dx = (icc[2, 1] - icc[0, 1]) / (4 * icc[1, 1] - 2 * icc[2, 1] - 2 * icc[0, 1])
dy = (icc[1, 2] - icc[1, 0]) / (4 * icc[1, 1] - 2 * icc[1, 2] - 2 * icc[1, 0])
# TODO work out what error is raised
except IndexError or Exception:
except (IndexError, Exception):
dx, dy = (
0,
0,
Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/utils/configuration_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def check_cupy_gpu(gratuitously_verbose: bool, **kwargs):
d = cp.cuda.Device(i)
hasattr(d, "attributes")
# TODO work out what error is raised
except AttributeError or Exception:
except (AttributeError, Exception):
num_gpus_detected = i
break

Expand Down

0 comments on commit fbbc232

Please sign in to comment.