Skip to content

Commit

Permalink
updating all __init__ files to be lite_aware
Browse files Browse the repository at this point in the history
  • Loading branch information
gvarnavi committed Jul 11, 2024
1 parent 1693c18 commit f75992c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 14 deletions.
6 changes: 4 additions & 2 deletions py4DSTEM/braggvectors/diskdetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
8 changes: 5 additions & 3 deletions py4DSTEM/io/filereaders/__init__.py
Original file line number Diff line number Diff line change
@@ -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
12 changes: 8 additions & 4 deletions py4DSTEM/process/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from py4DSTEM import is_package_lite
from py4DSTEM.process.polar import PolarDatacube
from py4DSTEM.process.strain.strain import StrainMap

Expand All @@ -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
6 changes: 4 additions & 2 deletions py4DSTEM/process/phase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
23 changes: 20 additions & 3 deletions py4DSTEM/utils/configuration_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ####
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f75992c

Please sign in to comment.