diff --git a/py4DSTEM/braggvectors/diskdetection.py b/py4DSTEM/braggvectors/diskdetection.py index a66ff62ea..500dbd2e9 100644 --- a/py4DSTEM/braggvectors/diskdetection.py +++ b/py4DSTEM/braggvectors/diskdetection.py @@ -5,6 +5,7 @@ from scipy.ndimage import gaussian_filter from emdfile import tqdmnd +from py4DSTEM import is_package_lite from py4DSTEM.braggvectors.braggvectors import BraggVectors from py4DSTEM.data import QPoints from py4DSTEM.datacube import DataCube @@ -13,8 +14,9 @@ try: from py4DSTEM.braggvectors.diskdetection_aiml import find_Bragg_disks_aiml -except (ImportError, ModuleNotFoundError): - pass +except (ImportError, ModuleNotFoundError) as exc: + if not is_package_lite: + raise exc def find_Bragg_disks( diff --git a/py4DSTEM/io/filereaders/__init__.py b/py4DSTEM/io/filereaders/__init__.py index 372275f11..4b89175a7 100644 --- a/py4DSTEM/io/filereaders/__init__.py +++ b/py4DSTEM/io/filereaders/__init__.py @@ -1,10 +1,12 @@ +from py4DSTEM import is_package_lite +from py4DSTEM.io.filereaders.empad import read_empad from py4DSTEM.io.filereaders.read_dm import read_dm from py4DSTEM.io.filereaders.read_K2 import read_gatan_K2_bin -from py4DSTEM.io.filereaders.empad import read_empad from py4DSTEM.io.filereaders.read_mib import load_mib try: from py4DSTEM.io.filereaders.read_arina import read_arina -except (ImportError, ModuleNotFoundError): - pass +except (ImportError, ModuleNotFoundError) as exc: + if not is_package_lite: + raise exc from py4DSTEM.io.filereaders.read_abTEM import read_abTEM diff --git a/py4DSTEM/process/__init__.py b/py4DSTEM/process/__init__.py index b04451913..6d7d36b28 100644 --- a/py4DSTEM/process/__init__.py +++ b/py4DSTEM/process/__init__.py @@ -1,3 +1,4 @@ +from py4DSTEM import is_package_lite from py4DSTEM.process.polar import PolarDatacube from py4DSTEM.process.strain.strain import StrainMap @@ -7,11 +8,14 @@ try: from py4DSTEM.process import classification -except (ImportError, ModuleNotFoundError): - pass +except (ImportError, ModuleNotFoundError) as exc: + if not is_package_lite: + raise exc + from py4DSTEM.process import diffraction try: from py4DSTEM.process import wholepatternfit -except (ImportError, ModuleNotFoundError): - pass +except (ImportError, ModuleNotFoundError) as exc: + if not is_package_lite: + raise exc diff --git a/py4DSTEM/process/phase/__init__.py b/py4DSTEM/process/phase/__init__.py index 927e5a08a..68dac8989 100644 --- a/py4DSTEM/process/phase/__init__.py +++ b/py4DSTEM/process/phase/__init__.py @@ -2,6 +2,7 @@ _emd_hook = True +from py4DSTEM import is_package_lite from py4DSTEM.process.phase.dpc import DPC from py4DSTEM.process.phase.magnetic_ptychographic_tomography import MagneticPtychographicTomography from py4DSTEM.process.phase.magnetic_ptychography import MagneticPtychography @@ -13,7 +14,8 @@ from py4DSTEM.process.phase.singleslice_ptychography import SingleslicePtychography try: from py4DSTEM.process.phase.parameter_optimize import OptimizationParameter, PtychographyOptimizer -except (ImportError, ModuleNotFoundError): - pass +except (ImportError, ModuleNotFoundError) as exc: + if not is_package_lite: + raise exc # fmt: on diff --git a/py4DSTEM/utils/configuration_checker.py b/py4DSTEM/utils/configuration_checker.py index cbdbd2881..2d292618e 100644 --- a/py4DSTEM/utils/configuration_checker.py +++ b/py4DSTEM/utils/configuration_checker.py @@ -5,8 +5,19 @@ import re from importlib.util import find_spec +from py4DSTEM import is_package_lite + # need a mapping of pypi/conda names to import names -import_mapping_dict = {} +import_mapping_dict = ( + {} + if is_package_lite + else { + "scikit-image": "skimage", + "scikit-learn": "sklearn", + "scikit-optimize": "skopt", + "mp-api": "mp_api", + } +) # programatically get all possible requirements in the import name style @@ -84,7 +95,7 @@ def get_modules_dict(): # module_depenencies = get_modules_dict() # modules = get_modules_list() -modules = [] +modules = [] if is_package_lite else get_modules_list() #### Class and Functions to Create Coloured Strings #### @@ -522,7 +533,13 @@ def print_no_extra_checks(m: str): # dict of extra check functions -funcs_dict = {} +funcs_dict = ( + {} + if is_package_lite + else { + "cupy": check_cupy_gpu, + } +) #### main function used to check the configuration of the installation