Skip to content

Commit ae42b25

Browse files
committedJan 26, 2022
Added numpy type hints and fixed isort
1 parent 8a54eef commit ae42b25

36 files changed

+405
-307
lines changed
 

‎.isort.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[settings]
2+
py_version = 37
3+
profile = "black"

‎pyproject.toml

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@
1818
[build-system]
1919
requires = ["setuptools", "numpy"]
2020
build-backend = "setuptools.build_meta"
21+
22+
[tool.isort]
23+
py_version = 37
24+
profile = "black"

‎requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pylint
33
flake8
44
flake8-docstrings
55
flake8-bugbear
6-
flake8-import-order
6+
flake8-isort
77
black
88
pycodestyle
99
mypy

‎requirements-qt.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
PyQt5
2+
PyQt5-stubs
23
pyqtgraph

‎src/om/algorithms/crystallography.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
import h5py # type: ignore
3030
import numpy
31-
from typing_extensions import TypedDict
3231
from numpy.typing import NDArray
32+
from typing_extensions import TypedDict
3333

3434
from om.lib.peakfinder8_extension import peakfinder_8 # type: ignore
3535
from om.utils import parameters as param_utils
@@ -207,7 +207,7 @@ class Peakfinder8PeakDetection:
207207
def __init__(
208208
self,
209209
*,
210-
radius_pixel_map: NDArray[numpy.float],
210+
radius_pixel_map: NDArray[numpy.float_],
211211
parameters: Dict[str, Any],
212212
) -> None:
213213
"""
@@ -385,38 +385,38 @@ def __init__(
385385
map_hdf5_file_handle: Any
386386
with h5py.File(bad_pixel_map_filename, "r") as map_hdf5_file_handle:
387387
self._bad_pixel_map: Union[
388-
NDArray[numpy.int], None
388+
NDArray[numpy.int_], None
389389
] = map_hdf5_file_handle[bad_pixel_map_hdf5_path][:]
390390
except (IOError, OSError, KeyError) as exc:
391391
exc_type, exc_value = sys.exc_info()[:2]
392392
# TODO: Fix type check
393-
exc_type_name = exc_type.__name__
394393
raise RuntimeError(
395-
f"The following error occurred while reading the "
394+
"The following error occurred while reading the " # type: ignore
396395
f"{bad_pixel_map_hdf5_path} field from the "
397396
f"{bad_pixel_map_filename} bad pixel map HDF5 file:"
398-
f"{exc_type_name}: {exc_value}"
397+
f"{exc_type.__name__}: {exc_value}"
399398
) from exc
400399
else:
401400
self._bad_pixel_map = None
402401

403-
self._radius_pixel_map: NDArray[numpy.float] = radius_pixel_map
402+
self._mask: Union[NDArray[numpy.int_], None] = None
403+
self._radius_pixel_map: NDArray[numpy.float_] = radius_pixel_map
404404

405405
def set_peakfinder8_info(self, peakfinder8_info: TypePeakfinder8Info) -> None:
406406
self._asic_nx = peakfinder8_info["asic_nx"]
407407
self._asic_ny = peakfinder8_info["asic_ny"]
408408
self._nasics_x = peakfinder8_info["nasics_x"]
409409
self._nasics_y = peakfinder8_info["nasics_y"]
410410

411-
def get_bad_pixel_mask(self) -> Union[NDArray[numpy.int], None]:
411+
def get_bad_pixel_mask(self) -> Union[NDArray[numpy.int_], None]:
412412
return self._bad_pixel_mask
413413

414414
def set_bad_pixel_mask(
415-
self, bad_pixel_mask: Union[NDArray[numpy.int], None]
415+
self, bad_pixel_mask: Union[NDArray[numpy.int_], None]
416416
) -> None:
417417
self._bad_pixel_mask = bad_pixel_mask
418418

419-
def set_radius_pixel_map(self, radius_pixel_map: NDArray[numpy / float]) -> None:
419+
def set_radius_pixel_map(self, radius_pixel_map: NDArray[numpy.float_]) -> None:
420420
self._radius_pixel_map = radius_pixel_map.astype(numpy.float32)
421421

422422
def get_adc_thresh(self) -> float:
@@ -621,7 +621,7 @@ def set_max_res(self, max_res: int) -> None:
621621
self._max_res = max_res
622622
self._mask = None
623623

624-
def find_peaks(self, *, data: NDArray[numpy.float]) -> TypePeakList:
624+
def find_peaks(self, *, data: NDArray[numpy.float_]) -> TypePeakList:
625625
"""
626626
Finds peaks in a detector data frame.
627627

0 commit comments

Comments
 (0)
Please sign in to comment.