Skip to content

Commit

Permalink
💬 Use CapWords for class name used TypedDict, such as ScanDesc, Prove…
Browse files Browse the repository at this point in the history
…nance, SampleInfo, etc.
  • Loading branch information
arafune committed Mar 14, 2024
1 parent ebcbf53 commit 1056050
Show file tree
Hide file tree
Showing 37 changed files with 230 additions and 232 deletions.
2 changes: 1 addition & 1 deletion docs/source/writing-interactive-tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ A next step is to display the original data.
self.add_controls()
self.update_data()
def set_data(self, data: DataType):
def set_data(self, data: XrTypes):
self.data = normalize_to_spectrum(data)
To display the data, we added logic in the ``before_show`` `lifecycle
Expand Down
49 changes: 24 additions & 25 deletions src/arpes/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import numpy as np
from _typeshed import Incomplete
from matplotlib.artist import Artist
from matplotlib.axes import Axes
from matplotlib.backend_bases import Event
from matplotlib.colors import Colormap, Normalize
from matplotlib.figure import Figure
Expand Down Expand Up @@ -66,13 +65,13 @@
"DataType",
"NormalizableDataType",
"XrTypes",
"SPECTROMETER",
"Spectrometer",
"MOMENTUM",
"EMISSION_ANGLE",
"ANGLE",
"CONFIGTYPE",
"WORKSPACETYPE",
"ANALYZERINFO",
"WorkSpaceType",
"ConfigType",
"AnalyzerInfo",
]


Expand Down Expand Up @@ -130,14 +129,14 @@ class ConfigSettings(TypedDict, total=False):
use_tex: bool


class WORKSPACETYPE(TypedDict, total=False):
class WorkSpaceType(TypedDict, total=False):
"""TypedDict for arpes.config.CONFIG["WORKSPACE"]."""

path: str | Path
name: str


class CURRENTCONTEXT(TypedDict, total=False):
class CurrentContext(TypedDict, total=False):
selected_components: list[float] # in widget.py, selected_components is [0, 1] is default
selected_indices: list[int]
sum_data: Incomplete
Expand All @@ -155,11 +154,11 @@ class CURRENTCONTEXT(TypedDict, total=False):
axis_Y_input: mpl.widgets.TextBox


class CONFIGTYPE(TypedDict, total=False):
class ConfigType(TypedDict, total=False):
"""TypedDict for arpes.config.CONFIG."""

WORKSPACE: Required[WORKSPACETYPE]
CURRENT_CONTEXT: CURRENTCONTEXT | None # see widgets.py
WORKSPACE: Required[WorkSpaceType]
CURRENT_CONTEXT: CurrentContext | None # see widgets.py
ENABLE_LOGGING: Required[bool]
LOGGING_STARTED: Required[bool]
LOGGING_FILE: Required[str | Path | None]
Expand All @@ -168,7 +167,7 @@ class CONFIGTYPE(TypedDict, total=False):
#
# TypedDict for ARPES.attrs
#
class COORDINATES(TypedDict, total=False):
class Coordinates(TypedDict, total=False):
"""TypedDict for attrs."""

x: NDArray[np.float_] | float
Expand All @@ -182,7 +181,7 @@ class COORDINATES(TypedDict, total=False):
phi: NDArray[np.float_] | float


class ANALYZERINFO(TypedDict, total=False):
class AnalyzerInfo(TypedDict, total=False):
"""TypedDict for attrs.
see analyzer_info in xarray_extensions.py
Expand All @@ -209,7 +208,7 @@ class ANALYZERINFO(TypedDict, total=False):
is_slit_vertical: bool


class _PUMPINFO(TypedDict, total=False):
class _PumpInfo(TypedDict, total=False):
"""TypedDict for attrs.
see pump_info in xarray_extensions.py
Expand All @@ -230,7 +229,7 @@ class _PUMPINFO(TypedDict, total=False):
pump_polarization_alpha: float


class _PROBEINFO(TypedDict, total=False):
class _ProbeInfo(TypedDict, total=False):
"""TypedDict for attrs.
see probe_info in xarray_extensions.py
Expand All @@ -251,7 +250,7 @@ class _PROBEINFO(TypedDict, total=False):
probe_polarization_alpha: float


class _BEAMLINEINFO(TypedDict, total=False):
class _BeamLineInfo(TypedDict, total=False):
"""TypedDict for attrs.
see beamline_info in xarray_extensions.py
Expand All @@ -275,15 +274,15 @@ class BeamLineSettings(TypedDict, total=False):
grating: str | None


class LIGHTSOURCEINFO(_PROBEINFO, _PUMPINFO, _BEAMLINEINFO, total=False):
class LightSourceInfo(_ProbeInfo, _PumpInfo, _BeamLineInfo, total=False):
polarization: float | tuple[float, float] | str
photon_flux: float
photocurrent: float
probe: Incomplete
probe_detail: Incomplete


class SAMPLEINFO(TypedDict, total=False):
class SampleInfo(TypedDict, total=False):
"""TypedDict for attrs.
see sample_info in xarray_extensions
Expand All @@ -295,7 +294,7 @@ class SAMPLEINFO(TypedDict, total=False):
reflectivity: float


class SCANINFO(TypedDict, total=False):
class ScanInfo(TypedDict, total=False):
time: str
date: str
spectrum_type: Literal["cut", "map", "hv_map", "ucut", "spem", "xps"]
Expand All @@ -307,7 +306,7 @@ class SCANINFO(TypedDict, total=False):
temperature_cryotip: float


class DAQINFO(TypedDict, total=False):
class DAQInfo(TypedDict, total=False):
"""TypedDict for attrs.
see daq_info in xarray_extensions.py
Expand All @@ -325,7 +324,7 @@ class DAQINFO(TypedDict, total=False):
frame_duration: float


class SPECTROMETER(ANALYZERINFO, COORDINATES, DAQINFO, total=False):
class Spectrometer(AnalyzerInfo, Coordinates, DAQInfo, total=False):
name: str
type: str
rad_per_pixel: float
Expand All @@ -336,16 +335,16 @@ class SPECTROMETER(ANALYZERINFO, COORDINATES, DAQINFO, total=False):
length: float


class EXPERIMENTINFO(
SCANINFO,
LIGHTSOURCEINFO,
ANALYZERINFO,
class ExperimentInfo(
ScanInfo,
LightSourceInfo,
AnalyzerInfo,
total=False,
):
pass


class ARPESAttrs(SPECTROMETER, LIGHTSOURCEINFO, SAMPLEINFO, total=False):
class ARPESAttrs(Spectrometer, LightSourceInfo, SampleInfo, total=False):
angle_unit: Literal["Degrees", "Radians", "deg", "rad"]
energy_notation: Literal[
"Binding",
Expand Down
4 changes: 2 additions & 2 deletions src/arpes/analysis/decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from sklearn.decomposition import FactorAnalysis, FastICA

from arpes.constants import TWO_DIMENSION
from arpes.provenance import PROVENANCE, provenance
from arpes.provenance import Provenance, provenance
from arpes.utilities import normalize_to_spectrum

if TYPE_CHECKING:
Expand Down Expand Up @@ -166,7 +166,7 @@ def decomposition_along(
if stacked:
into = into.unstack("fit_axis")

provenance_context: PROVENANCE = {
provenance_context: Provenance = {
"what": "sklearn decomposition",
"by": "decomposition_along",
"axes": axes,
Expand Down
2 changes: 1 addition & 1 deletion src/arpes/analysis/deconvolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def deconvolve_ice(
The PSF is the impulse response of a focused optical imaging system.
Args:
data (DataType): input data
data (xr.DataArray): input data
psf(NDArray[np.float_): array as point spread function
n_iterations: the number of convolutions to use for the fit
deg: the degree of the fitting polynominial
Expand Down
8 changes: 4 additions & 4 deletions src/arpes/analysis/derivative.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
import xarray as xr

from arpes.provenance import PROVENANCE, provenance, update_provenance
from arpes.provenance import Provenance, provenance, update_provenance
from arpes.utilities import normalize_to_spectrum

if TYPE_CHECKING:
Expand Down Expand Up @@ -175,7 +175,7 @@ def warpped_filter(arr: xr.DataArray):

if "id" in arr.attrs:
filterd_arr.attrs["id"] = arr.attrs["id"] + "_CV"
provenance_context: PROVENANCE = {"what": "Maximum Curvature", "by": "1D", "alpha": alpha}
provenance_context: Provenance = {"what": "Maximum Curvature", "by": "1D", "alpha": alpha}
provenance(filterd_arr, arr, provenance_context)
return filterd_arr

Expand Down Expand Up @@ -239,7 +239,7 @@ def warpped_filter(arr: xr.DataArray):

if "id" in curv.attrs:
del curv.attrs["id"]
provenance_context: PROVENANCE = {
provenance_context: Provenance = {
"what": "Curvature",
"by": "2D_with_weight",
"directions": directions,
Expand Down Expand Up @@ -288,7 +288,7 @@ def dn_along_axis(

if "id" in dn_arr.attrs:
dn_arr.attrs["id"] = dn_arr.attrs["id"] + f"_dy{order}"
provenance_context: PROVENANCE = {
provenance_context: Provenance = {
"what": f"{order}th derivative",
"by": "dn_along_axis",
"axis": dim,
Expand Down
6 changes: 3 additions & 3 deletions src/arpes/analysis/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import xarray as xr
from scipy import ndimage

from arpes.provenance import PROVENANCE, provenance
from arpes.provenance import Provenance, provenance

if TYPE_CHECKING:
from collections.abc import Callable, Hashable
Expand Down Expand Up @@ -61,7 +61,7 @@ def gaussian_filter_arr(
filtered_arr = xr.DataArray(values, arr.coords, arr.dims, attrs=arr.attrs)
if "id" in filtered_arr.attrs:
del filtered_arr.attrs["id"]
provenance_context: PROVENANCE = {
provenance_context: Provenance = {
"what": "Gaussian filtered data",
"by": "gaussian_filter_arr",
"sigma": sigma,
Expand Down Expand Up @@ -117,7 +117,7 @@ def boxcar_filter_arr(
filtered_arr = xr.DataArray(array_values, arr.coords, arr.dims, attrs=arr.attrs)
if "id" in arr.attrs:
del filtered_arr.attrs["id"]
provenance_context: PROVENANCE = {
provenance_context: Provenance = {
"what": "Boxcar filtered data",
"by": "boxcar_filter_arr",
"size": size,
Expand Down
6 changes: 3 additions & 3 deletions src/arpes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import pint

if TYPE_CHECKING:
from ._typing import CONFIGTYPE, WORKSPACETYPE, ConfigSettings
from ._typing import ConfigSettings, ConfigType, WorkSpaceType

# pylint: disable=global-statement

Expand Down Expand Up @@ -63,7 +63,7 @@
FIGURE_PATH: str | Path | None = None
DATASET_PATH: str | Path | None = None

CONFIG: CONFIGTYPE = {
CONFIG: ConfigType = {
"WORKSPACE": {},
"CURRENT_CONTEXT": None,
"ENABLE_LOGGING": True,
Expand Down Expand Up @@ -127,7 +127,7 @@ def __init__(self, workspace_name: str = "") -> None:
ToDo: TEST
"""
self._cached_workspace: WORKSPACETYPE = {}
self._cached_workspace: WorkSpaceType = {}
self._workspace_name: str = workspace_name

def __enter__(self) -> None:
Expand Down
20 changes: 10 additions & 10 deletions src/arpes/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from numpy import pi

if TYPE_CHECKING:
from ._typing import SPECTROMETER
from ._typing import Spectrometer

# eV, A reasonablish value if you aren't sure for the particular sample
WORK_FUNCTION = 4.3
Expand Down Expand Up @@ -52,21 +52,21 @@
#
#

SPECTROMETER_MC: SPECTROMETER = {
SPECTROMETER_MC: Spectrometer = {
"name": "MC",
"rad_per_pixel": (1 / 10) * (pi / 180),
"type": "hemisphere",
"is_slit_vertical": False,
}

SPECTROMETER_MC_OLD: SPECTROMETER = {
SPECTROMETER_MC_OLD: Spectrometer = {
"name": "MC_OLD",
"type": "hemisphere",
"rad_per_pixel": 0.125 * (pi / 180),
"is_slit_vertical": False,
}

SPECTROMETER_STRAIGHT_TOF: SPECTROMETER = {
SPECTROMETER_STRAIGHT_TOF: Spectrometer = {
"name": "STRAIGHT_ToF",
"length": STRAIGHT_TOF_LENGTH,
"mstar": 1.0,
Expand All @@ -75,7 +75,7 @@
"scan_dof": ["theta"],
}

SPECTROMETER_SPIN_TOF: SPECTROMETER = {
SPECTROMETER_SPIN_TOF: Spectrometer = {
"name": "SPIN_ToF",
"length": SPIN_TOF_LENGTH,
"mstar": 0.5,
Expand All @@ -84,7 +84,7 @@
"scan_dof": ["theta", "beta"],
}

SPECTROMETER_DLD: SPECTROMETER = {
SPECTROMETER_DLD: Spectrometer = {
"name": "DLD",
"length": DLD_LENGTH,
"type": "tof",
Expand All @@ -95,28 +95,28 @@
"scan_dof": ["theta"],
}

SPECTROMETER_BL4: SPECTROMETER = {
SPECTROMETER_BL4: Spectrometer = {
"name": "BL4",
"is_slit_vertical": True,
"type": "hemisphere",
"dof": ["theta", "sample_phi"],
}

SPECTROMETER_BL7: SPECTROMETER = {
SPECTROMETER_BL7: Spectrometer = {
"name": "BL7",
"is_slit_vertical": True,
"type": "hemisphere",
"dof": ["theta", "sample_phi"],
}

SPECTROMETER_ANTARES: SPECTROMETER = {
SPECTROMETER_ANTARES: Spectrometer = {
"name": "ANTARES",
"is_slit_vertical": True,
"type": "hemisphere",
"dof": ["theta", "sample_phi"],
}

SPECTROMETER_KAINDL: SPECTROMETER = {
SPECTROMETER_KAINDL: Spectrometer = {
"name": "Kaindl",
"is_slit_vertical": True,
"type": "hemisphere",
Expand Down
Loading

0 comments on commit 1056050

Please sign in to comment.