diff --git a/arpes/config.py b/arpes/config.py index b4befd3f..ce649ab9 100644 --- a/arpes/config.py +++ b/arpes/config.py @@ -26,7 +26,7 @@ import pint if TYPE_CHECKING: - from arpes._typing import CONFIGTYPE, ConfigSettings + from arpes._typing import CONFIGTYPE, WORKSPACETYPE, ConfigSettings # pylint: disable=global-statement @@ -124,8 +124,8 @@ def __init__(self, workspace: str | None = None) -> None: Args: workspace: The name of the workspace to enter temporarily. Defaults to None. """ - self._cached_workspace: CONFIGTYPE = {} - self._workspace = workspace + self._cached_workspace: WORKSPACETYPE = {} + self._workspace: str | None = workspace def __enter__(self) -> None: """Caches the current workspace and enters a new one. diff --git a/arpes/corrections/background.py b/arpes/corrections/background.py index 945a86aa..ec011b3b 100644 --- a/arpes/corrections/background.py +++ b/arpes/corrections/background.py @@ -25,8 +25,8 @@ def remove_incoherent_background(data: DataType, *, set_zero: bool = True) -> xr pulses). Args: - data: - set_zero: + data (DataType): input ARPES data + set_zero (bool): set zero if the negative value is obtained after background subtraction. Returns: Data with a background subtracted. diff --git a/arpes/models/__init__.py b/arpes/models/__init__.py index fe16b72f..3dba8923 100644 --- a/arpes/models/__init__.py +++ b/arpes/models/__init__.py @@ -1,4 +1,4 @@ """Rudimentary band analysis code.""" from __future__ import annotations -from .band import * +from .band import BackgroundBand, Band, MultifitBand, VoigtBand diff --git a/arpes/simulation.py b/arpes/simulation.py index 2d33f8b8..e2e5e7ae 100644 --- a/arpes/simulation.py +++ b/arpes/simulation.py @@ -150,7 +150,10 @@ class WindowedDetectorEffect(DetectorEffect): """TODO model the finite width of the detector window as recorded on a camera.""" -def cloud_to_arr(point_cloud, shape) -> NDArray[np.float_]: +def cloud_to_arr( + point_cloud: list[list[float]], + shape: tuple[int, int], +) -> NDArray[np.float_]: """Converts a point cloud (list of xy pairs) to an array representation. Uses linear interpolation for points that have non-integral coordinates. @@ -164,7 +167,7 @@ def cloud_to_arr(point_cloud, shape) -> NDArray[np.float_]: """ cloud_as_image = np.zeros(shape) - for x, y in zip(*point_cloud): + for x, y in zip(*point_cloud, strict=True): frac_low_x = 1 - (x - np.floor(x)) frac_low_y = 1 - (y - np.floor(y)) shape_x, shape_y = shape @@ -174,9 +177,9 @@ def cloud_to_arr(point_cloud, shape) -> NDArray[np.float_]: cloud_as_image[(int(np.floor(x)) + 1) % shape_x][int(np.floor(y)) % shape_y] += ( 1 - frac_low_x ) * frac_low_y - cloud_as_image[int(np.floor(x)) % shape_x][ - (int(np.floor(y)) + 1) % shape_y - ] += frac_low_x * (1 - frac_low_y) + cloud_as_image[int(np.floor(x)) % shape_x][(int(np.floor(y)) + 1) % shape_y] += ( + frac_low_x * (1 - frac_low_y) + ) cloud_as_image[(int(np.floor(x)) + 1) % shape_x][(int(np.floor(y)) + 1) % shape_y] += ( 1 - frac_low_x ) * (1 - frac_low_y) @@ -185,8 +188,8 @@ def cloud_to_arr(point_cloud, shape) -> NDArray[np.float_]: def apply_psf_to_point_cloud( - point_cloud, - shape, + point_cloud: list[list[float]], + shape: tuple[int, int], sigma: tuple[int, int] = (10, 3), ) -> NDArray[np.float_]: """Takes a point cloud and turns it into a broadened spectrum. @@ -220,9 +223,9 @@ def sample_from_distribution( sample individual events coming from this PDF. Args: - distribution: The probability density. The probability of drawing a sample at (i, j) - will be proportional to `distribution[i, j]`. - N: The desired number of electrons/samples to pull from the distribution. + distribution(xr.DataArray): The probability density. The probability of drawing a + sample at (i, j) will be proportional to `distribution[i, j]`. + n(int): The desired number of electrons/samples to pull from the distribution. Returns: An array with the arrival locations. @@ -347,7 +350,7 @@ def sampled_spectral_function( spectral = self.measured_spectral_function() sampled = [ apply_psf_to_point_cloud( - sample_from_distribution(spectral, N=n_electrons), + sample_from_distribution(spectral, n=n_electrons), spectral.values.shape, sigma=psf, ) diff --git a/arpes/utilities/qt/help_dialogs.py b/arpes/utilities/qt/help_dialogs.py index f8e14d2b..537545c9 100644 --- a/arpes/utilities/qt/help_dialogs.py +++ b/arpes/utilities/qt/help_dialogs.py @@ -9,15 +9,16 @@ from arpes.utilities.ui import PRETTY_KEYS, label, vertical if TYPE_CHECKING: - from _typeshed import Incomplete from PySide6.QtGui import QKeyEvent + + from arpes.utilities.ui import KeyBinding __all__ = ("BasicHelpDialog",) class BasicHelpDialog(QtWidgets.QDialog): """A help dialog showing keyboard shortcuts for Qt application.""" - def __init__(self, shortcuts: Incomplete | None = None) -> None: + def __init__(self, shortcuts: list[KeyBinding] | None = None) -> None: """Initialize the help window and build widgets for the registered shortcuts.""" super().__init__() @@ -65,6 +66,6 @@ def __init__(self, shortcuts: Incomplete | None = None) -> None: def keyPressEvent(self, event: QKeyEvent) -> None: """If the user preset H we should toggle the dialog, or close it if they pressed Esc.""" - if event.key() == QtCore.Qt.Key_H or event.key() == QtCore.Qt.Key_Escape: + if event.key() == QtCore.Qt.Key.Key_H or event.key() == QtCore.Qt.Key.Key_Escape: self._main_window._help_dialog = None # pylint: disable=protected-access self.close() diff --git a/arpes/utilities/ui.py b/arpes/utilities/ui.py index 67d99ac9..13deb4ba 100644 --- a/arpes/utilities/ui.py +++ b/arpes/utilities/ui.py @@ -147,7 +147,7 @@ class CursorMode(NamedTuple): PRETTY_KEYS = {} -for key, value in vars(QtCore.Qt).items(): +for key, value in vars(QtCore.Qt.Key).items(): if isinstance(value, QtCore.Qt.Key): PRETTY_KEYS[value] = key.partition("_")[2] diff --git a/arpes/xarray_extensions.py b/arpes/xarray_extensions.py index 39b87901..06a25307 100644 --- a/arpes/xarray_extensions.py +++ b/arpes/xarray_extensions.py @@ -706,7 +706,7 @@ def iter_symmetry_points(self) -> Generator[tuple[str, float], None, None]: yield from self.iter_projected_symmetry_points @property - def history(self): + def history(self) -> dict: provenance_recorded = self._obj.attrs.get("provenance", None) def unlayer(prov: dict[str, Incomplete] | None) -> tuple[list[Incomplete], Incomplete]: