Skip to content
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

Change how cupy import fall-through is handled #533

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions py4DSTEM/braggvectors/diskdetection_aiml_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions py4DSTEM/preprocess/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

try:
import cupy as cp
except ImportError:
cp = None
except ModuleNotFoundError:
cp = np


def bin2D(array, factor, dtype=np.float64):
Expand Down
4 changes: 2 additions & 2 deletions py4DSTEM/process/phase/iterative_base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions py4DSTEM/process/phase/iterative_dpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions py4DSTEM/process/phase/iterative_mixedstate_ptychography.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions py4DSTEM/process/phase/iterative_multislice_ptychography.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions py4DSTEM/process/phase/iterative_overlap_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions py4DSTEM/process/phase/iterative_parallax.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

try:
import cupy as cp
except ImportError:
cp = None
except ModuleNotFoundError:
cp = np

warnings.simplefilter(action="always", category=UserWarning)

Expand Down
4 changes: 2 additions & 2 deletions py4DSTEM/process/phase/iterative_simultaneous_ptychography.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions py4DSTEM/process/phase/iterative_singleslice_ptychography.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions py4DSTEM/process/utils/cross_correlate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
4 changes: 2 additions & 2 deletions py4DSTEM/process/utils/multicorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
4 changes: 2 additions & 2 deletions py4DSTEM/process/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down