Skip to content

Commit

Permalink
Merge pull request #533 from sezelt/cp-import
Browse files Browse the repository at this point in the history
Change how `cupy` import fall-through is handled
  • Loading branch information
bsavitzky authored Oct 16, 2023
2 parents 8d5b2e0 + 74c60d4 commit e8305e7
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 28 deletions.
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

0 comments on commit e8305e7

Please sign in to comment.