Skip to content

Commit

Permalink
F401 - unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-rakowski committed Nov 10, 2023
1 parent 79b2559 commit 0b20634
Show file tree
Hide file tree
Showing 50 changed files with 33 additions and 112 deletions.
2 changes: 1 addition & 1 deletion py4DSTEM/braggvectors/braggvectors.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 8 additions & 17 deletions py4DSTEM/braggvectors/diskdetection_aiml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions py4DSTEM/braggvectors/diskdetection_aiml_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 1 addition & 9 deletions py4DSTEM/braggvectors/diskdetection_parallel_new.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
import numpy as np
import matplotlib.pyplot as plt
import h5py
import time
import dill

import dask
import dask.array as da
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


Expand Down
2 changes: 0 additions & 2 deletions py4DSTEM/data/calibration.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/datacube/datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion py4DSTEM/io/filereaders/read_arina.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import h5py
import hdf5plugin
import numpy as np
from py4DSTEM.datacube import DataCube
from py4DSTEM.preprocess.utils import bin2D
Expand Down
1 change: 0 additions & 1 deletion py4DSTEM/io/filereaders/read_dm.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/io/legacy/legacy12/read_v0_12.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions py4DSTEM/io/legacy/legacy12/read_v0_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions py4DSTEM/io/legacy/legacy12/read_v0_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions py4DSTEM/io/legacy/legacy12/read_v0_7.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion py4DSTEM/io/legacy/legacy12/read_v0_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion py4DSTEM/io/legacy/legacy13/v13_emd_classes/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions py4DSTEM/io/legacy/legacy13/v13_emd_classes/metadata.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 0 additions & 2 deletions py4DSTEM/io/legacy/legacy13/v13_emd_classes/pointlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions py4DSTEM/io/legacy/legacy13/v13_emd_classes/pointlistarray.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions py4DSTEM/io/legacy/legacy13/v13_emd_classes/root.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from typing import Optional, Union
import numpy as np
import h5py


class DataCube(Array):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from typing import Optional, Union
import numpy as np
import h5py


class DiffractionSlice(Array):
Expand Down
1 change: 0 additions & 1 deletion py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/io.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 2 additions & 3 deletions py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/probe.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
3 changes: 1 addition & 2 deletions py4DSTEM/io/legacy/legacy13/v13_py4dstem_classes/qpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from typing import Optional, Union
import numpy as np
import h5py


class RealSlice(Array):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from typing import Optional, Union
import numpy as np
import h5py


class VirtualDiffraction(DiffractionSlice):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from typing import Optional, Union
import numpy as np
import h5py


class VirtualImage(RealSlice):
Expand Down
1 change: 0 additions & 1 deletion py4DSTEM/io/legacy/legacy13/v13_to_14.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
Calibration,
DiffractionSlice,
RealSlice,
QPoints,
)
from py4DSTEM.datacube import (
DataCube,
Expand Down
4 changes: 1 addition & 3 deletions py4DSTEM/io/legacy/read_legacy_12.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
1 change: 0 additions & 1 deletion py4DSTEM/io/legacy/read_legacy_13.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion py4DSTEM/io/legacy/read_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Utility functions

import h5py
import numpy as np


def get_py4DSTEM_topgroups(filepath):
Expand Down
2 changes: 0 additions & 2 deletions py4DSTEM/preprocess/electroncount.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion py4DSTEM/preprocess/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###

Expand Down
Loading

0 comments on commit 0b20634

Please sign in to comment.