From 0b20634251d2c80eabe5db3d79aace7760e374a7 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Fri, 10 Nov 2023 01:30:59 -0800 Subject: [PATCH] F401 - unused imports --- py4DSTEM/braggvectors/braggvectors.py | 2 +- py4DSTEM/braggvectors/diskdetection_aiml.py | 25 ++++++------------- .../braggvectors/diskdetection_aiml_cuda.py | 3 +-- .../diskdetection_parallel_new.py | 10 +------- py4DSTEM/data/calibration.py | 2 -- py4DSTEM/datacube/datacube.py | 2 +- py4DSTEM/io/filereaders/read_arina.py | 1 - py4DSTEM/io/filereaders/read_dm.py | 1 - py4DSTEM/io/legacy/legacy12/read_v0_12.py | 2 +- py4DSTEM/io/legacy/legacy12/read_v0_5.py | 2 -- py4DSTEM/io/legacy/legacy12/read_v0_6.py | 2 -- py4DSTEM/io/legacy/legacy12/read_v0_7.py | 2 -- py4DSTEM/io/legacy/legacy12/read_v0_9.py | 2 +- .../legacy/legacy13/v13_emd_classes/array.py | 1 - .../legacy13/v13_emd_classes/metadata.py | 2 -- .../legacy13/v13_emd_classes/pointlist.py | 2 -- .../v13_emd_classes/pointlistarray.py | 2 -- .../legacy/legacy13/v13_emd_classes/root.py | 3 --- .../v13_py4dstem_classes/braggvectors.py | 2 -- .../legacy13/v13_py4dstem_classes/datacube.py | 1 - .../v13_py4dstem_classes/diffractionslice.py | 1 - .../legacy13/v13_py4dstem_classes/io.py | 1 - .../legacy13/v13_py4dstem_classes/probe.py | 5 ++-- .../legacy13/v13_py4dstem_classes/qpoints.py | 3 +-- .../v13_py4dstem_classes/realslice.py | 1 - .../virtualdiffraction.py | 1 - .../v13_py4dstem_classes/virtualimage.py | 1 - py4DSTEM/io/legacy/legacy13/v13_to_14.py | 1 - py4DSTEM/io/legacy/read_legacy_12.py | 4 +-- py4DSTEM/io/legacy/read_legacy_13.py | 1 - py4DSTEM/io/legacy/read_utils.py | 1 - py4DSTEM/preprocess/electroncount.py | 2 -- py4DSTEM/preprocess/preprocess.py | 1 - py4DSTEM/process/calibration/origin.py | 6 ++--- py4DSTEM/process/calibration/qpixelsize.py | 3 --- py4DSTEM/process/calibration/rotation.py | 1 - py4DSTEM/process/diffraction/crystal_bloch.py | 1 - .../process/diffraction/crystal_calibrate.py | 6 ++--- py4DSTEM/process/diffraction/crystal_phase.py | 3 +-- py4DSTEM/process/diffraction/crystal_viz.py | 8 +++--- py4DSTEM/process/diffraction/flowlines.py | 4 +-- py4DSTEM/process/polar/polar_datacube.py | 2 +- py4DSTEM/process/polar/polar_peaks.py | 2 +- py4DSTEM/process/rdf/rdf.py | 2 +- py4DSTEM/process/strain/strain.py | 3 --- py4DSTEM/process/utils/utils.py | 3 +-- py4DSTEM/process/wholepatternfit/wpf_viz.py | 2 -- py4DSTEM/utils/configuration_checker.py | 2 +- py4DSTEM/visualize/vis_RQ.py | 1 - py4DSTEM/visualize/vis_special.py | 4 --- 50 files changed, 33 insertions(+), 112 deletions(-) diff --git a/py4DSTEM/braggvectors/braggvectors.py b/py4DSTEM/braggvectors/braggvectors.py index daaf9816e..333a4b395 100644 --- a/py4DSTEM/braggvectors/braggvectors.py +++ b/py4DSTEM/braggvectors/braggvectors.py @@ -1,7 +1,7 @@ # Defines the BraggVectors class from py4DSTEM.data import Data -from emdfile import Custom, PointListArray, PointList, Metadata +from emdfile import Custom, PointListArray, Metadata from py4DSTEM.braggvectors.braggvector_methods import BraggVectorMethods from os.path import basename import numpy as np diff --git a/py4DSTEM/braggvectors/diskdetection_aiml.py b/py4DSTEM/braggvectors/diskdetection_aiml.py index 68c01a851..2284202e4 100644 --- a/py4DSTEM/braggvectors/diskdetection_aiml.py +++ b/py4DSTEM/braggvectors/diskdetection_aiml.py @@ -4,16 +4,14 @@ """ import os -import glob import json import shutil import numpy as np +from importlib.util import find_spec -from scipy.ndimage import gaussian_filter from time import time -from numbers import Number -from emdfile import tqdmnd, PointList, PointListArray +from emdfile import tqdmnd from py4DSTEM.braggvectors.braggvectors import BraggVectors from py4DSTEM.data import QPoints from py4DSTEM.process.utils import get_maxima_2D @@ -100,10 +98,8 @@ def find_Bragg_disks_aiml_single_DP( Returns: (PointList): the Bragg peak positions and correlation intensities - """ - try: - import crystal4D - except: + """ + if find_spec("crystal4D") is None: raise ImportError("Import Error: Please install crystal4D before proceeding") try: import tensorflow as tf @@ -254,9 +250,8 @@ def find_Bragg_disks_aiml_selected( correlation intensities at each scan position (Rx,Ry). """ - try: - import crystal4D - except: + if find_spec("crystal4D") is None: + raise ImportError("Import Error: Please install crystal4D before proceeding") assert len(Rx) == len(Ry) @@ -431,9 +426,7 @@ def find_Bragg_disks_aiml_serial( (PointListArray): the Bragg peak positions and correlation intensities """ - try: - import crystal4D - except: + if find_spec("crystal4D") is None: raise ImportError("Import Error: Please install crystal4D before proceeding") # Make the peaks PointListArray @@ -641,9 +634,7 @@ def find_Bragg_disks_aiml( Returns: (PointListArray): the Bragg peak positions and correlation intensities """ - try: - import crystal4D - except: + if find_spec("crystal4D") is None: raise ImportError("Please install crystal4D before proceeding") def _parse_distributed(distributed): diff --git a/py4DSTEM/braggvectors/diskdetection_aiml_cuda.py b/py4DSTEM/braggvectors/diskdetection_aiml_cuda.py index 98e5e1a8d..d82aefd43 100644 --- a/py4DSTEM/braggvectors/diskdetection_aiml_cuda.py +++ b/py4DSTEM/braggvectors/diskdetection_aiml_cuda.py @@ -8,8 +8,7 @@ from emdfile import tqdmnd from py4DSTEM.braggvectors.braggvectors import BraggVectors -from emdfile import PointList, PointListArray -from py4DSTEM.data import QPoints +from emdfile import PointList from py4DSTEM.braggvectors.kernels import kernels from py4DSTEM.braggvectors.diskdetection_aiml import _get_latest_model diff --git a/py4DSTEM/braggvectors/diskdetection_parallel_new.py b/py4DSTEM/braggvectors/diskdetection_parallel_new.py index 6771cb9af..c5b27a8bc 100644 --- a/py4DSTEM/braggvectors/diskdetection_parallel_new.py +++ b/py4DSTEM/braggvectors/diskdetection_parallel_new.py @@ -1,7 +1,4 @@ import numpy as np -import matplotlib.pyplot as plt -import h5py -import time import dill import dask @@ -9,16 +6,11 @@ import dask.config from dask import delayed from dask.distributed import Client, LocalCluster -from dask.diagnostics import ProgressBar -# import dask.bag as db - -# import distributed from distributed.protocol.serialize import register_serialization_family import distributed -import py4DSTEM -from emdfile import PointListArray, PointList +from emdfile import PointListArray from py4DSTEM.braggvectors.diskdetection import _find_Bragg_disks_single_DP_FK diff --git a/py4DSTEM/data/calibration.py b/py4DSTEM/data/calibration.py index cd9a7c9aa..8281cc8e7 100644 --- a/py4DSTEM/data/calibration.py +++ b/py4DSTEM/data/calibration.py @@ -1,9 +1,7 @@ # Defines the Calibration class, which stores calibration metadata import numpy as np -from numbers import Number from typing import Optional -from warnings import warn from emdfile import Metadata, Root from py4DSTEM.data.propagating_calibration import call_calibrate diff --git a/py4DSTEM/datacube/datacube.py b/py4DSTEM/datacube/datacube.py index 62da23e1e..9306613b8 100644 --- a/py4DSTEM/datacube/datacube.py +++ b/py4DSTEM/datacube/datacube.py @@ -12,7 +12,7 @@ ) from typing import Optional, Union -from emdfile import Array, Metadata, Node, Root, tqdmnd +from emdfile import Array, Metadata, Node, tqdmnd from py4DSTEM.data import Data, Calibration from py4DSTEM.datacube.virtualimage import DataCubeVirtualImager from py4DSTEM.datacube.virtualdiffraction import DataCubeVirtualDiffraction diff --git a/py4DSTEM/io/filereaders/read_arina.py b/py4DSTEM/io/filereaders/read_arina.py index 6f7c463d2..71973fbd4 100644 --- a/py4DSTEM/io/filereaders/read_arina.py +++ b/py4DSTEM/io/filereaders/read_arina.py @@ -1,5 +1,4 @@ import h5py -import hdf5plugin import numpy as np from py4DSTEM.datacube import DataCube from py4DSTEM.preprocess.utils import bin2D diff --git a/py4DSTEM/io/filereaders/read_dm.py b/py4DSTEM/io/filereaders/read_dm.py index 617529708..118eff6ec 100644 --- a/py4DSTEM/io/filereaders/read_dm.py +++ b/py4DSTEM/io/filereaders/read_dm.py @@ -1,7 +1,6 @@ # Reads a digital micrograph 4D-STEM dataset import numpy as np -from pathlib import Path from ncempy.io import dm from emdfile import tqdmnd, Array diff --git a/py4DSTEM/io/legacy/legacy12/read_v0_12.py b/py4DSTEM/io/legacy/legacy12/read_v0_12.py index 4f028f698..6622a5a2b 100644 --- a/py4DSTEM/io/legacy/legacy12/read_v0_12.py +++ b/py4DSTEM/io/legacy/legacy12/read_v0_12.py @@ -2,7 +2,7 @@ import h5py import numpy as np -from os.path import splitext, exists +from os.path import exists from py4DSTEM.io.legacy.read_utils import ( is_py4DSTEM_file, get_py4DSTEM_topgroups, diff --git a/py4DSTEM/io/legacy/legacy12/read_v0_5.py b/py4DSTEM/io/legacy/legacy12/read_v0_5.py index 7a7e2141c..3a19c5a4c 100644 --- a/py4DSTEM/io/legacy/legacy12/read_v0_5.py +++ b/py4DSTEM/io/legacy/legacy12/read_v0_5.py @@ -2,12 +2,10 @@ import h5py import numpy as np -from os.path import splitext from py4DSTEM.io.legacy.read_utils import ( is_py4DSTEM_file, get_py4DSTEM_topgroups, get_py4DSTEM_version, - version_is_geq, ) from py4DSTEM.io.legacy.legacy12.read_utils_v0_5 import get_py4DSTEM_dataobject_info from emdfile import PointList, PointListArray diff --git a/py4DSTEM/io/legacy/legacy12/read_v0_6.py b/py4DSTEM/io/legacy/legacy12/read_v0_6.py index 40c80c82b..4f0149473 100644 --- a/py4DSTEM/io/legacy/legacy12/read_v0_6.py +++ b/py4DSTEM/io/legacy/legacy12/read_v0_6.py @@ -2,12 +2,10 @@ import h5py import numpy as np -from os.path import splitext from py4DSTEM.io.legacy.read_utils import ( is_py4DSTEM_file, get_py4DSTEM_topgroups, get_py4DSTEM_version, - version_is_geq, ) from py4DSTEM.io.legacy.legacy12.read_utils_v0_6 import get_py4DSTEM_dataobject_info from emdfile import PointList, PointListArray diff --git a/py4DSTEM/io/legacy/legacy12/read_v0_7.py b/py4DSTEM/io/legacy/legacy12/read_v0_7.py index ed4a363cb..d94c55fab 100644 --- a/py4DSTEM/io/legacy/legacy12/read_v0_7.py +++ b/py4DSTEM/io/legacy/legacy12/read_v0_7.py @@ -2,12 +2,10 @@ import h5py import numpy as np -from os.path import splitext from py4DSTEM.io.legacy.read_utils import ( is_py4DSTEM_file, get_py4DSTEM_topgroups, get_py4DSTEM_version, - version_is_geq, ) from py4DSTEM.io.legacy.legacy12.read_utils_v0_7 import get_py4DSTEM_dataobject_info from emdfile import PointList, PointListArray diff --git a/py4DSTEM/io/legacy/legacy12/read_v0_9.py b/py4DSTEM/io/legacy/legacy12/read_v0_9.py index 5084e7339..75bf91233 100644 --- a/py4DSTEM/io/legacy/legacy12/read_v0_9.py +++ b/py4DSTEM/io/legacy/legacy12/read_v0_9.py @@ -2,7 +2,7 @@ import h5py import numpy as np -from os.path import splitext, exists +from os.path import exists from py4DSTEM.io.legacy.read_utils import ( is_py4DSTEM_file, get_py4DSTEM_topgroups, diff --git a/py4DSTEM/io/legacy/legacy13/v13_emd_classes/array.py b/py4DSTEM/io/legacy/legacy13/v13_emd_classes/array.py index a5192ffa6..23d94b77e 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_emd_classes/array.py +++ b/py4DSTEM/io/legacy/legacy13/v13_emd_classes/array.py @@ -3,7 +3,6 @@ from typing import Optional, Union import numpy as np -import h5py from numbers import Number from py4DSTEM.io.legacy.legacy13.v13_emd_classes.tree import Tree diff --git a/py4DSTEM/io/legacy/legacy13/v13_emd_classes/metadata.py b/py4DSTEM/io/legacy/legacy13/v13_emd_classes/metadata.py index d430528e1..e8e756965 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_emd_classes/metadata.py +++ b/py4DSTEM/io/legacy/legacy13/v13_emd_classes/metadata.py @@ -1,7 +1,5 @@ import numpy as np -from numbers import Number from typing import Optional -import h5py from py4DSTEM.io.legacy.legacy13.v13_emd_classes.tree import Tree diff --git a/py4DSTEM/io/legacy/legacy13/v13_emd_classes/pointlist.py b/py4DSTEM/io/legacy/legacy13/v13_emd_classes/pointlist.py index c7f0c7fc1..4621211b4 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_emd_classes/pointlist.py +++ b/py4DSTEM/io/legacy/legacy13/v13_emd_classes/pointlist.py @@ -3,8 +3,6 @@ # structured arrays. import numpy as np -import h5py -from copy import copy from typing import Optional from py4DSTEM.io.legacy.legacy13.v13_emd_classes.tree import Tree diff --git a/py4DSTEM/io/legacy/legacy13/v13_emd_classes/pointlistarray.py b/py4DSTEM/io/legacy/legacy13/v13_emd_classes/pointlistarray.py index c246672bd..7e27f21ca 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_emd_classes/pointlistarray.py +++ b/py4DSTEM/io/legacy/legacy13/v13_emd_classes/pointlistarray.py @@ -1,7 +1,5 @@ import numpy as np -from copy import copy from typing import Optional -import h5py from py4DSTEM.io.legacy.legacy13.v13_emd_classes.tree import Tree from py4DSTEM.io.legacy.legacy13.v13_emd_classes.metadata import Metadata diff --git a/py4DSTEM/io/legacy/legacy13/v13_emd_classes/root.py b/py4DSTEM/io/legacy/legacy13/v13_emd_classes/root.py index c5137d9f4..39a36ab5a 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_emd_classes/root.py +++ b/py4DSTEM/io/legacy/legacy13/v13_emd_classes/root.py @@ -1,7 +1,4 @@ -import numpy as np -from numbers import Number from typing import Optional -import h5py from py4DSTEM.io.legacy.legacy13.v13_emd_classes.tree import Tree diff --git a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/braggvectors.py b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/braggvectors.py index 4e51bdebf..91471bd83 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/braggvectors.py +++ b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/braggvectors.py @@ -1,9 +1,7 @@ # Defines the BraggVectors class -from typing import Optional, Union import numpy as np -import h5py from py4DSTEM.io.legacy.legacy13.v13_emd_classes import PointListArray from py4DSTEM.io.legacy.legacy13.v13_emd_classes.tree import Tree diff --git a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/datacube.py b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/datacube.py index 979579d49..a341cb3f8 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/datacube.py +++ b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/datacube.py @@ -6,7 +6,6 @@ from typing import Optional, Union import numpy as np -import h5py class DataCube(Array): diff --git a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/diffractionslice.py b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/diffractionslice.py index b32877a4a..60e29af33 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/diffractionslice.py +++ b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/diffractionslice.py @@ -5,7 +5,6 @@ from typing import Optional, Union import numpy as np -import h5py class DiffractionSlice(Array): diff --git a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/io.py b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/io.py index 2556ebe8f..23fd9fee6 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/io.py +++ b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/io.py @@ -1,6 +1,5 @@ # Functions for reading and writing subclasses of the base EMD types -import numpy as np import h5py from os.path import basename diff --git a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/probe.py b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/probe.py index cd1c7d9d9..284616241 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/probe.py +++ b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/probe.py @@ -1,14 +1,13 @@ # Defines the Probe class, which stores vacuum probes # and cross-correlation kernels derived from them -from py4DSTEM.io.legacy.legacy13.v13_emd_classes.array import Array, Metadata +from py4DSTEM.io.legacy.legacy13.v13_emd_classes.array import Metadata from py4DSTEM.io.legacy.legacy13.v13_py4dstem_classes.diffractionslice import ( DiffractionSlice, ) -from typing import Optional, Union +from typing import Optional import numpy as np -import h5py class Probe(DiffractionSlice): diff --git a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/qpoints.py b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/qpoints.py index 3429c4c8d..e9fa51723 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/qpoints.py +++ b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/qpoints.py @@ -2,9 +2,8 @@ from py4DSTEM.io.legacy.legacy13.v13_emd_classes.pointlist import PointList -from typing import Optional, Union +from typing import Optional import numpy as np -import h5py class QPoints(PointList): diff --git a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/realslice.py b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/realslice.py index 367401055..a560e613b 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/realslice.py +++ b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/realslice.py @@ -2,7 +2,6 @@ from typing import Optional, Union import numpy as np -import h5py class RealSlice(Array): diff --git a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/virtualdiffraction.py b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/virtualdiffraction.py index 188f1d646..7adc89a8e 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/virtualdiffraction.py +++ b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/virtualdiffraction.py @@ -8,7 +8,6 @@ from typing import Optional, Union import numpy as np -import h5py class VirtualDiffraction(DiffractionSlice): diff --git a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/virtualimage.py b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/virtualimage.py index 4d6c38845..2feb96c62 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/virtualimage.py +++ b/py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/virtualimage.py @@ -6,7 +6,6 @@ from typing import Optional, Union import numpy as np -import h5py class VirtualImage(RealSlice): diff --git a/py4DSTEM/io/legacy/legacy13/v13_to_14.py b/py4DSTEM/io/legacy/legacy13/v13_to_14.py index 650529b22..28e634eef 100644 --- a/py4DSTEM/io/legacy/legacy13/v13_to_14.py +++ b/py4DSTEM/io/legacy/legacy13/v13_to_14.py @@ -34,7 +34,6 @@ Calibration, DiffractionSlice, RealSlice, - QPoints, ) from py4DSTEM.datacube import ( DataCube, diff --git a/py4DSTEM/io/legacy/read_legacy_12.py b/py4DSTEM/io/legacy/read_legacy_12.py index 40bfcfc94..68aafcada 100644 --- a/py4DSTEM/io/legacy/read_legacy_12.py +++ b/py4DSTEM/io/legacy/read_legacy_12.py @@ -1,8 +1,6 @@ # File reader for py4DSTEM files -import h5py -import numpy as np -from os.path import splitext, exists +from os.path import exists from py4DSTEM.io.legacy.read_utils import is_py4DSTEM_file, get_py4DSTEM_topgroups from py4DSTEM.io.legacy.read_utils import get_py4DSTEM_version, version_is_geq from py4DSTEM.io.legacy.legacy12 import ( diff --git a/py4DSTEM/io/legacy/read_legacy_13.py b/py4DSTEM/io/legacy/read_legacy_13.py index 04da1e65a..43f666ebd 100644 --- a/py4DSTEM/io/legacy/read_legacy_13.py +++ b/py4DSTEM/io/legacy/read_legacy_13.py @@ -1,7 +1,6 @@ # File reader for py4DSTEM v13 files import h5py -import numpy as np import warnings from os.path import exists, basename, dirname, join from typing import Optional, Union diff --git a/py4DSTEM/io/legacy/read_utils.py b/py4DSTEM/io/legacy/read_utils.py index c11f93b60..128213a70 100644 --- a/py4DSTEM/io/legacy/read_utils.py +++ b/py4DSTEM/io/legacy/read_utils.py @@ -1,7 +1,6 @@ # Utility functions import h5py -import numpy as np def get_py4DSTEM_topgroups(filepath): diff --git a/py4DSTEM/preprocess/electroncount.py b/py4DSTEM/preprocess/electroncount.py index d3c2edd9a..e54899bdb 100644 --- a/py4DSTEM/preprocess/electroncount.py +++ b/py4DSTEM/preprocess/electroncount.py @@ -144,7 +144,6 @@ def electron_count_GPU( See electron_count() for additional documentation. """ import torch - import dm assert isinstance(output, str), "output must be a str" assert output in [ @@ -417,7 +416,6 @@ def counted_pointlistarray_to_datacube(counted_pointlistarray, shape, subpixel=F if __name__ == "__main__": - from py4DSTEM.process.preprocess import get_darkreference from py4DSTEM.io import DataCube, save from ncempy.io import dm diff --git a/py4DSTEM/preprocess/preprocess.py b/py4DSTEM/preprocess/preprocess.py index 9febf229a..e70fed06f 100644 --- a/py4DSTEM/preprocess/preprocess.py +++ b/py4DSTEM/preprocess/preprocess.py @@ -11,7 +11,6 @@ import numpy as np from py4DSTEM.preprocess.utils import bin2D, get_shifted_ar from emdfile import tqdmnd -from scipy.ndimage import median_filter ### Editing datacube shape ### diff --git a/py4DSTEM/process/calibration/origin.py b/py4DSTEM/process/calibration/origin.py index 78a90fbef..fe410e777 100644 --- a/py4DSTEM/process/calibration/origin.py +++ b/py4DSTEM/process/calibration/origin.py @@ -1,15 +1,13 @@ # Find the origin of diffraction space -import functools import numpy as np from scipy.ndimage import gaussian_filter -from scipy.optimize import leastsq -from emdfile import tqdmnd, PointListArray +from emdfile import tqdmnd from py4DSTEM.datacube import DataCube from py4DSTEM.process.calibration.probe import get_probe_size from py4DSTEM.process.fit import plane, parabola, bezier_two, fit_2D -from py4DSTEM.process.utils import get_CoM, add_to_2D_array_from_floats, get_maxima_2D +from py4DSTEM.process.utils import get_CoM # diff --git a/py4DSTEM/process/calibration/qpixelsize.py b/py4DSTEM/process/calibration/qpixelsize.py index 2abefd54c..9d0c5eded 100644 --- a/py4DSTEM/process/calibration/qpixelsize.py +++ b/py4DSTEM/process/calibration/qpixelsize.py @@ -2,10 +2,7 @@ import numpy as np from scipy.optimize import leastsq -from typing import Union, Optional -from emdfile import tqdmnd -from py4DSTEM.process.utils import get_CoM def get_Q_pixel_size(q_meas, q_known, units="A"): diff --git a/py4DSTEM/process/calibration/rotation.py b/py4DSTEM/process/calibration/rotation.py index aaf8a49ce..eec4b3d4a 100644 --- a/py4DSTEM/process/calibration/rotation.py +++ b/py4DSTEM/process/calibration/rotation.py @@ -1,7 +1,6 @@ # Rotational calibrations import numpy as np -from typing import Optional import matplotlib.pyplot as plt from py4DSTEM import show diff --git a/py4DSTEM/process/diffraction/crystal_bloch.py b/py4DSTEM/process/diffraction/crystal_bloch.py index 6a3c9b1ac..31e7b94f7 100644 --- a/py4DSTEM/process/diffraction/crystal_bloch.py +++ b/py4DSTEM/process/diffraction/crystal_bloch.py @@ -1,4 +1,3 @@ -import warnings import numpy as np import numpy.lib.recfunctions as rfn from scipy import linalg diff --git a/py4DSTEM/process/diffraction/crystal_calibrate.py b/py4DSTEM/process/diffraction/crystal_calibrate.py index c068bf79e..e07005468 100644 --- a/py4DSTEM/process/diffraction/crystal_calibrate.py +++ b/py4DSTEM/process/diffraction/crystal_calibrate.py @@ -1,13 +1,13 @@ import numpy as np -from typing import Union, Optional +from typing import Union from scipy.optimize import curve_fit -from py4DSTEM.process.diffraction.utils import Orientation, calc_1D_profile +from py4DSTEM.process.diffraction.utils import calc_1D_profile try: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.core.structure import Structure -except ImportError: +except (ImportError, ModuleNotFoundError): pass diff --git a/py4DSTEM/process/diffraction/crystal_phase.py b/py4DSTEM/process/diffraction/crystal_phase.py index 84824fe63..6ab48cde8 100644 --- a/py4DSTEM/process/diffraction/crystal_phase.py +++ b/py4DSTEM/process/diffraction/crystal_phase.py @@ -5,8 +5,7 @@ import matplotlib.pyplot as plt from emdfile import tqdmnd, PointListArray -from py4DSTEM.visualize import show, show_image_grid -from py4DSTEM.process.diffraction.crystal_viz import plot_diffraction_pattern +from py4DSTEM.visualize import show_image_grid class Crystal_Phase: diff --git a/py4DSTEM/process/diffraction/crystal_viz.py b/py4DSTEM/process/diffraction/crystal_viz.py index 9c5b0a0f2..3318215ae 100644 --- a/py4DSTEM/process/diffraction/crystal_viz.py +++ b/py4DSTEM/process/diffraction/crystal_viz.py @@ -1,18 +1,16 @@ import matplotlib.pyplot as plt -from matplotlib.figure import Figure -from matplotlib.axes import Axes import matplotlib.tri as mtri -from mpl_toolkits.mplot3d import Axes3D, art3d +from mpl_toolkits.mplot3d import art3d from scipy.signal import medfilt from scipy.ndimage import gaussian_filter from scipy.ndimage.morphology import distance_transform_edt -from skimage.morphology import dilation, erosion +from skimage.morphology import erosion import warnings import numpy as np from typing import Union, Optional -from emdfile import tqdmnd, PointList, PointListArray +from emdfile import tqdmnd, PointList from py4DSTEM.process.diffraction.utils import calc_1D_profile diff --git a/py4DSTEM/process/diffraction/flowlines.py b/py4DSTEM/process/diffraction/flowlines.py index 66904d4f8..fbb01e603 100644 --- a/py4DSTEM/process/diffraction/flowlines.py +++ b/py4DSTEM/process/diffraction/flowlines.py @@ -3,15 +3,13 @@ import numpy as np import matplotlib.pyplot as plt -from matplotlib.figure import Figure -from matplotlib.axes import Axes from scipy.ndimage import gaussian_filter1d from matplotlib.colors import hsv_to_rgb from matplotlib.colors import rgb_to_hsv from matplotlib.colors import ListedColormap -from emdfile import tqdmnd, PointList, PointListArray +from emdfile import tqdmnd, PointListArray def make_orientation_histogram( diff --git a/py4DSTEM/process/polar/polar_datacube.py b/py4DSTEM/process/polar/polar_datacube.py index 56071c534..6ba741953 100644 --- a/py4DSTEM/process/polar/polar_datacube.py +++ b/py4DSTEM/process/polar/polar_datacube.py @@ -1,6 +1,6 @@ import numpy as np from py4DSTEM.datacube import DataCube -from scipy.ndimage import binary_opening, binary_closing, gaussian_filter1d +from scipy.ndimage import gaussian_filter1d class PolarDatacube: diff --git a/py4DSTEM/process/polar/polar_peaks.py b/py4DSTEM/process/polar/polar_peaks.py index be9ae989e..a7bb4f847 100644 --- a/py4DSTEM/process/polar/polar_peaks.py +++ b/py4DSTEM/process/polar/polar_peaks.py @@ -4,7 +4,7 @@ from scipy.ndimage import gaussian_filter, gaussian_filter1d from scipy.signal import peak_prominences from skimage.feature import peak_local_max -from scipy.optimize import curve_fit, leastsq +from scipy.optimize import curve_fit import warnings # from emdfile import tqdmnd, PointList, PointListArray diff --git a/py4DSTEM/process/rdf/rdf.py b/py4DSTEM/process/rdf/rdf.py index cee7eeee9..d09c8a35f 100644 --- a/py4DSTEM/process/rdf/rdf.py +++ b/py4DSTEM/process/rdf/rdf.py @@ -4,7 +4,7 @@ import numpy as np from scipy.special import erf -from scipy.fftpack import dst, idst +from scipy.fftpack import dst from py4DSTEM.process.utils import single_atom_scatter diff --git a/py4DSTEM/process/strain/strain.py b/py4DSTEM/process/strain/strain.py index ab8a46a9a..1d2dbf3bc 100644 --- a/py4DSTEM/process/strain/strain.py +++ b/py4DSTEM/process/strain/strain.py @@ -13,7 +13,6 @@ from py4DSTEM.data import Data, RealSlice from py4DSTEM.preprocess.utils import get_maxima_2D from py4DSTEM.process.strain.latticevectors import ( - add_indices_to_braggvectors, fit_lattice_vectors_all_DPs, get_reference_g1g2, get_rotated_strain_map, @@ -25,8 +24,6 @@ add_bragg_index_labels, add_pointlabels, add_vector, - ax_addaxes, - ax_addaxes_QtoR, ) diff --git a/py4DSTEM/process/utils/utils.py b/py4DSTEM/process/utils/utils.py index 4ef2e1d8a..f77578f5a 100644 --- a/py4DSTEM/process/utils/utils.py +++ b/py4DSTEM/process/utils/utils.py @@ -11,8 +11,7 @@ import matplotlib.font_manager as fm from emdfile import tqdmnd -from py4DSTEM.process.utils.multicorr import upsampled_correlation -from py4DSTEM.preprocess.utils import make_Fourier_coords2D +from py4DSTEM.preprocess.utils import make_Fourier_coords2D # TODO this is defined later try: from IPython.display import clear_output diff --git a/py4DSTEM/process/wholepatternfit/wpf_viz.py b/py4DSTEM/process/wholepatternfit/wpf_viz.py index ac32e88f7..6ad8fbc20 100644 --- a/py4DSTEM/process/wholepatternfit/wpf_viz.py +++ b/py4DSTEM/process/wholepatternfit/wpf_viz.py @@ -1,9 +1,7 @@ -from typing import Optional import numpy as np import matplotlib.pyplot as plt import matplotlib.colors as mpl_c -from matplotlib.gridspec import GridSpec from py4DSTEM.process.wholepatternfit.wp_models import WPFModelType diff --git a/py4DSTEM/utils/configuration_checker.py b/py4DSTEM/utils/configuration_checker.py index 26b0b89d5..785b91b97 100644 --- a/py4DSTEM/utils/configuration_checker.py +++ b/py4DSTEM/utils/configuration_checker.py @@ -1,11 +1,11 @@ #### this file contains a function/s that will check if various # libaries/compute options are available import importlib -from operator import mod # list of modules we expect/may expect to be installed # as part of a standard py4DSTEM installation # this needs to be the import name e.g. import mp_api not mp-api +# TODO use importlib.metadata.requirements to populate modules = [ "crystal4D", "cupy", diff --git a/py4DSTEM/visualize/vis_RQ.py b/py4DSTEM/visualize/vis_RQ.py index 85c0eb042..8d111b2b6 100644 --- a/py4DSTEM/visualize/vis_RQ.py +++ b/py4DSTEM/visualize/vis_RQ.py @@ -1,6 +1,5 @@ import numpy as np import matplotlib.pyplot as plt -from matplotlib.axes import Axes from py4DSTEM.visualize.show import show, show_points diff --git a/py4DSTEM/visualize/vis_special.py b/py4DSTEM/visualize/vis_special.py index 84584f368..689cc451c 100644 --- a/py4DSTEM/visualize/vis_special.py +++ b/py4DSTEM/visualize/vis_special.py @@ -4,18 +4,14 @@ from mpl_toolkits.axes_grid1 import make_axes_locatable from scipy.spatial import Voronoi -from emdfile import PointList from py4DSTEM.visualize import show from py4DSTEM.visualize.overlay import ( add_pointlabels, - add_vector, - add_bragg_index_labels, add_ellipses, add_points, add_scalebar, ) from py4DSTEM.visualize.vis_grid import show_image_grid -from py4DSTEM.visualize.vis_RQ import ax_addaxes, ax_addaxes_QtoR from colorspacious import cspace_convert