From d4d1b19472b85cf2e3fa287e26a97b3b1131cbcc Mon Sep 17 00:00:00 2001 From: Ryuichi Arafune Date: Mon, 26 Feb 2024 22:57:50 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AC=20=20Update=20type=20hints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/api.rst | 3 ++- docs/source/dev-guide.rst | 7 +++---- src/arpes/__init__.py | 4 ++-- src/arpes/_typing.py | 1 - src/arpes/analysis/deconvolution.py | 1 + src/arpes/config.py | 1 - src/arpes/io.py | 2 +- src/arpes/provenance.py | 2 ++ src/arpes/utilities/ui.py | 4 ++-- src/arpes/widgets.py | 5 ++++- src/arpes/workflow.py | 11 +++++------ src/arpes/xarray_extensions.py | 6 +++--- 12 files changed, 25 insertions(+), 22 deletions(-) diff --git a/docs/source/api.rst b/docs/source/api.rst index 45594075..10ad35c3 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -146,9 +146,10 @@ Deconvolution .. autosummary:: - analysis.deconvolution.make_psf1d analysis.deconvolution.deconvolve_ice analysis.deconvolution.deconvolve_rl + analysis.deconvolution.make_psf1d + analysis.deconvolution.make_psf Masks ~~~~~ diff --git a/docs/source/dev-guide.rst b/docs/source/dev-guide.rst index 2487ca00..cd6e0ffd 100644 --- a/docs/source/dev-guide.rst +++ b/docs/source/dev-guide.rst @@ -28,7 +28,7 @@ Running Tests .. code:: bash - pytest -vv --conv=ares --con-report=html tests/ + pytest -vv --conv=arpes --cov-report=html tests/ finally, you can view results at htmlcov/index.html @@ -80,6 +80,5 @@ encountered is due to bare hyperlinks, which are incompatible with the Style ~~~~~ -We don’t have any hard and fast style rules. As a coarse rule of thumb, -if your code scans well and doesn’t use too many short variable names -there’s no issue. +We strongly recommend to use "black" for formatting, and request "ruff" and "mypy" free coding. +And if your code scans well and doesn’t use too many short variable names there’s no issue. diff --git a/src/arpes/__init__.py b/src/arpes/__init__.py index 639e42bc..83ba33e1 100644 --- a/src/arpes/__init__.py +++ b/src/arpes/__init__.py @@ -31,12 +31,12 @@ def verify_qt_tool() -> str | None: return None def verify_igor_pro() -> str | None: - pip_command = "pip install https://github.com/arafune/igorpy/tarball/bbfaea#egg=igor-0.3.1" + pip_command = "pip install https://github.com/arafune/igorpy" warning = f"For Igor support, install igorpy with: {pip_command}" warning_incompatible = ( "PyARPES requires a patched copy of igorpy, " "available at \n\t" - "https://github.com/chstan/igorpy/tarball/712a4c4\n\n\tYou can install with: " + "https://github.com/arafune/igorpy: " f"{pip_command}" ) try: diff --git a/src/arpes/_typing.py b/src/arpes/_typing.py index 40165f48..bc85a1bc 100644 --- a/src/arpes/_typing.py +++ b/src/arpes/_typing.py @@ -126,7 +126,6 @@ class ConfigSettings(TypedDict, total=False): """TypedDict for arpes.config.SETTINGS.""" interactive: _InteractiveConfigSettings - xarray_repr_mod: bool use_tex: bool diff --git a/src/arpes/analysis/deconvolution.py b/src/arpes/analysis/deconvolution.py index 8d793b2b..66438dd8 100644 --- a/src/arpes/analysis/deconvolution.py +++ b/src/arpes/analysis/deconvolution.py @@ -27,6 +27,7 @@ "deconvolve_ice", "deconvolve_rl", "make_psf1d", + "make_psf", ) LOGLEVELS = (DEBUG, INFO) diff --git a/src/arpes/config.py b/src/arpes/config.py index 22f9bf97..5cf3623f 100644 --- a/src/arpes/config.py +++ b/src/arpes/config.py @@ -54,7 +54,6 @@ "marginal_width": 150, "palette": "magma", }, - "xarray_repr_mod": False, "use_tex": False, } diff --git a/src/arpes/io.py b/src/arpes/io.py index 7e2ed0a5..3fa50daf 100644 --- a/src/arpes/io.py +++ b/src/arpes/io.py @@ -55,7 +55,7 @@ def load_data( file: str | Path | int, - location: str | type | None = None, + location: str | None = None, **kwargs: Incomplete, ) -> xr.Dataset: """Loads a piece of data using available plugins. This the user facing API for data loading. diff --git a/src/arpes/provenance.py b/src/arpes/provenance.py index 32241b19..6b5f7803 100644 --- a/src/arpes/provenance.py +++ b/src/arpes/provenance.py @@ -74,9 +74,11 @@ class PROVENANCE(TypedDict, total=False): correction: list[NDArray[np.float_]] # fermi_edge_correction # dims: Sequence[str] + dim: str # old_axis: str new_axis: str + transformed_vars: list[str] # occupation_ratio: float diff --git a/src/arpes/utilities/ui.py b/src/arpes/utilities/ui.py index d03f257f..ce7a8139 100644 --- a/src/arpes/utilities/ui.py +++ b/src/arpes/utilities/ui.py @@ -154,7 +154,7 @@ class CursorMode(NamedTuple): supported_dimensions: Incomplete -PRETTY_KEYS: dict[Enum, str] = {} +PRETTY_KEYS: dict[Enum | int, str] = {} for key, value in vars(QtCore.Qt.Key).items(): if isinstance(value, QtCore.Qt.Key): PRETTY_KEYS[value] = key.partition("_")[2] @@ -193,7 +193,7 @@ def wrapped_ui_builder( logger.debug(f"id_ is: {id_}") if id_ is not None: try: - id_, ui = id_ + id_, ui = id_ # type: ignore[misc] except ValueError: ui = ACTIVE_UI logger.debug(f"f is :{f}") diff --git a/src/arpes/widgets.py b/src/arpes/widgets.py index a37d5c28..991379ef 100644 --- a/src/arpes/widgets.py +++ b/src/arpes/widgets.py @@ -965,7 +965,10 @@ def apply_offsets(event: Event) -> None: @popout -def pick_rectangles(data: DataType, **kwargs: Incomplete) -> list[list[float]]: +def pick_rectangles( + data: DataType, + **kwargs: Incomplete, +) -> list[list[float]]: """A utility allowing for selection of rectangular regions. Args: diff --git a/src/arpes/workflow.py b/src/arpes/workflow.py index 93636513..7ba597a7 100644 --- a/src/arpes/workflow.py +++ b/src/arpes/workflow.py @@ -25,18 +25,17 @@ reproducible analyses) and share code between notebooks using a local module. """ -from __future__ import annotations # noqa: I001 +from __future__ import annotations import subprocess import sys from collections import defaultdict from functools import wraps +from logging import DEBUG, INFO, Formatter, StreamHandler, getLogger from pathlib import Path from pprint import pprint from typing import TYPE_CHECKING, ParamSpec, TypeVar -from logging import INFO, Formatter, StreamHandler, getLogger - import dill from .config import WorkspaceManager @@ -60,8 +59,8 @@ "summarize_data", ) - -LOGLEVEL = INFO +LOGLEVELS = (DEBUG, INFO) +LOGLEVEL = LOGLEVELS[1] logger = getLogger(__name__) fmt = "%(asctime)s %(levelname)s %(name)s :%(message)s" formatter = Formatter(fmt) @@ -110,7 +109,7 @@ def _open_path(p: Path | str) -> None: if "win" in sys.platform: subprocess.Popen(rf"explorer {p}") else: - print(p) + logger.info(f"Path to open {p}") @with_workspace diff --git a/src/arpes/xarray_extensions.py b/src/arpes/xarray_extensions.py index bffcdeeb..7b831027 100644 --- a/src/arpes/xarray_extensions.py +++ b/src/arpes/xarray_extensions.py @@ -1730,9 +1730,9 @@ def _experimentalinfo_to_dict(conditions: EXPERIMENTINFO) -> dict[str, str]: if isinstance(v, xr.DataArray): min_hv = float(v.min()) max_hv = float(v.max()) - transformed_dict[ - k - ] = f" from {min_hv} to {max_hv} eV" + transformed_dict[k] = ( + f" from {min_hv} to {max_hv} eV" + ) elif isinstance(v, float) and not np.isnan(v): transformed_dict[k] = f"{v} eV" return transformed_dict