Skip to content

Commit

Permalink
💬 Update type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
arafune committed Feb 26, 2024
1 parent 299302d commit d4d1b19
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 22 deletions.
3 changes: 2 additions & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~
Expand Down
7 changes: 3 additions & 4 deletions docs/source/dev-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
4 changes: 2 additions & 2 deletions src/arpes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion src/arpes/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class ConfigSettings(TypedDict, total=False):
"""TypedDict for arpes.config.SETTINGS."""

interactive: _InteractiveConfigSettings
xarray_repr_mod: bool
use_tex: bool


Expand Down
1 change: 1 addition & 0 deletions src/arpes/analysis/deconvolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"deconvolve_ice",
"deconvolve_rl",
"make_psf1d",
"make_psf",
)

LOGLEVELS = (DEBUG, INFO)
Expand Down
1 change: 0 additions & 1 deletion src/arpes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"marginal_width": 150,
"palette": "magma",
},
"xarray_repr_mod": False,
"use_tex": False,
}

Expand Down
2 changes: 1 addition & 1 deletion src/arpes/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/arpes/provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/arpes/utilities/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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}")
Expand Down
5 changes: 4 additions & 1 deletion src/arpes/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 5 additions & 6 deletions src/arpes/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/arpes/xarray_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"<strong> from </strong> {min_hv} <strong> to </strong> {max_hv} eV"
transformed_dict[k] = (
f"<strong> from </strong> {min_hv} <strong> to </strong> {max_hv} eV"
)
elif isinstance(v, float) and not np.isnan(v):
transformed_dict[k] = f"{v} eV"
return transformed_dict
Expand Down

0 comments on commit d4d1b19

Please sign in to comment.