diff --git a/py4DSTEM/braggvectors/diskdetection_aiml_cuda.py b/py4DSTEM/braggvectors/diskdetection_aiml_cuda.py index d0f550dcc..c5f89b9fd 100644 --- a/py4DSTEM/braggvectors/diskdetection_aiml_cuda.py +++ b/py4DSTEM/braggvectors/diskdetection_aiml_cuda.py @@ -17,8 +17,8 @@ try: import cupy as cp -except: - raise ImportError("Import Error: Please install cupy before proceeding") +except ModuleNotFoundError: + raise ImportError("AIML CUDA Requires cupy") try: import tensorflow as tf diff --git a/py4DSTEM/preprocess/utils.py b/py4DSTEM/preprocess/utils.py index 0c76f35a7..752e2f81c 100644 --- a/py4DSTEM/preprocess/utils.py +++ b/py4DSTEM/preprocess/utils.py @@ -5,8 +5,8 @@ try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np def bin2D(array, factor, dtype=np.float64): diff --git a/py4DSTEM/process/phase/iterative_base_class.py b/py4DSTEM/process/phase/iterative_base_class.py index ae4c92d4b..6d7967550 100644 --- a/py4DSTEM/process/phase/iterative_base_class.py +++ b/py4DSTEM/process/phase/iterative_base_class.py @@ -13,8 +13,8 @@ try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np from emdfile import Array, Custom, Metadata, _read_metadata, tqdmnd from py4DSTEM.data import Calibration diff --git a/py4DSTEM/process/phase/iterative_dpc.py b/py4DSTEM/process/phase/iterative_dpc.py index 4c80ed177..02138d738 100644 --- a/py4DSTEM/process/phase/iterative_dpc.py +++ b/py4DSTEM/process/phase/iterative_dpc.py @@ -13,8 +13,8 @@ try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np from emdfile import Array, Custom, Metadata, _read_metadata, tqdmnd from py4DSTEM.data import Calibration diff --git a/py4DSTEM/process/phase/iterative_mixedstate_ptychography.py b/py4DSTEM/process/phase/iterative_mixedstate_ptychography.py index 56fec1004..ceae66cd8 100644 --- a/py4DSTEM/process/phase/iterative_mixedstate_ptychography.py +++ b/py4DSTEM/process/phase/iterative_mixedstate_ptychography.py @@ -14,8 +14,8 @@ try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np from emdfile import Custom, tqdmnd from py4DSTEM import DataCube diff --git a/py4DSTEM/process/phase/iterative_multislice_ptychography.py b/py4DSTEM/process/phase/iterative_multislice_ptychography.py index a352502d0..aee383675 100644 --- a/py4DSTEM/process/phase/iterative_multislice_ptychography.py +++ b/py4DSTEM/process/phase/iterative_multislice_ptychography.py @@ -14,8 +14,8 @@ try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np from emdfile import Custom, tqdmnd from py4DSTEM import DataCube diff --git a/py4DSTEM/process/phase/iterative_overlap_magnetic_tomography.py b/py4DSTEM/process/phase/iterative_overlap_magnetic_tomography.py index 8691a121d..b09d18ca7 100644 --- a/py4DSTEM/process/phase/iterative_overlap_magnetic_tomography.py +++ b/py4DSTEM/process/phase/iterative_overlap_magnetic_tomography.py @@ -16,8 +16,8 @@ try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np from emdfile import Custom, tqdmnd from py4DSTEM import DataCube diff --git a/py4DSTEM/process/phase/iterative_overlap_tomography.py b/py4DSTEM/process/phase/iterative_overlap_tomography.py index d6bee12fd..1f6be1c38 100644 --- a/py4DSTEM/process/phase/iterative_overlap_tomography.py +++ b/py4DSTEM/process/phase/iterative_overlap_tomography.py @@ -16,8 +16,8 @@ try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np from emdfile import Custom, tqdmnd from py4DSTEM import DataCube diff --git a/py4DSTEM/process/phase/iterative_parallax.py b/py4DSTEM/process/phase/iterative_parallax.py index 80cdd8cd8..7c5896b6a 100644 --- a/py4DSTEM/process/phase/iterative_parallax.py +++ b/py4DSTEM/process/phase/iterative_parallax.py @@ -19,8 +19,8 @@ try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np warnings.simplefilter(action="always", category=UserWarning) diff --git a/py4DSTEM/process/phase/iterative_simultaneous_ptychography.py b/py4DSTEM/process/phase/iterative_simultaneous_ptychography.py index 8881d021c..e3713cde1 100644 --- a/py4DSTEM/process/phase/iterative_simultaneous_ptychography.py +++ b/py4DSTEM/process/phase/iterative_simultaneous_ptychography.py @@ -14,8 +14,8 @@ try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np from emdfile import Custom, tqdmnd from py4DSTEM import DataCube diff --git a/py4DSTEM/process/phase/iterative_singleslice_ptychography.py b/py4DSTEM/process/phase/iterative_singleslice_ptychography.py index 0480bae8a..df0ef5e1c 100644 --- a/py4DSTEM/process/phase/iterative_singleslice_ptychography.py +++ b/py4DSTEM/process/phase/iterative_singleslice_ptychography.py @@ -14,8 +14,8 @@ try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np from emdfile import Custom, tqdmnd from py4DSTEM.datacube import DataCube diff --git a/py4DSTEM/process/utils/cross_correlate.py b/py4DSTEM/process/utils/cross_correlate.py index f9aac1312..50de91e33 100644 --- a/py4DSTEM/process/utils/cross_correlate.py +++ b/py4DSTEM/process/utils/cross_correlate.py @@ -6,8 +6,8 @@ try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np def get_cross_correlation(ar, template, corrPower=1, _returnval="real"): diff --git a/py4DSTEM/process/utils/multicorr.py b/py4DSTEM/process/utils/multicorr.py index 8523c8e62..bc07390bb 100644 --- a/py4DSTEM/process/utils/multicorr.py +++ b/py4DSTEM/process/utils/multicorr.py @@ -15,8 +15,8 @@ try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np def upsampled_correlation(imageCorr, upsampleFactor, xyShift, device="cpu"): diff --git a/py4DSTEM/process/utils/utils.py b/py4DSTEM/process/utils/utils.py index 03d3d07a0..4ef2e1d8a 100644 --- a/py4DSTEM/process/utils/utils.py +++ b/py4DSTEM/process/utils/utils.py @@ -24,8 +24,8 @@ def clear_output(wait=True): try: import cupy as cp -except ImportError: - cp = None +except ModuleNotFoundError: + cp = np def radial_reduction(ar, x0, y0, binsize=1, fn=np.mean, coords=None):