Skip to content

Commit

Permalink
💬 update type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
arafune committed Oct 18, 2023
1 parent 6ce02ba commit ba61469
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arpes/xarray_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) -> list[dict[str, dict[str, str] | str | list[str]]]:
provenance_recorded = self._obj.attrs.get("provenance", None)

def unlayer(prov: dict[str, Incomplete] | None) -> tuple[list[Incomplete], Incomplete]:
Expand Down Expand Up @@ -1702,7 +1702,7 @@ def analyzer_detail(self) -> dict[str, str | float | None]:
}

@property
def temp(self) -> float:
def temp(self) -> float | Literal["RT", "LT"]:
"""The temperature at which an experiment was performed."""
prefered_attrs = [
"TA",
Expand All @@ -1722,7 +1722,7 @@ def temp(self) -> float:
]
for attr in prefered_attrs:
if attr in self._obj.attrs:
return float(self._obj.attrs[attr])
return self._obj.attrs[attr]

msg = "Could not read temperature off any standard attr"
raise AttributeError(msg)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_xarray_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ def test_location_and_endstation(self, dataset_cut: xr.Dataset) -> None:
"""Test for property endstation property."""
assert dataset_cut.S.endstation == "ALG-MC"

def test_history(self, dataarray_cut: xr.DataArray) -> None:
"""Test for S.history."""
history = dataarray_cut.S.history
assert history[0]["record"]["what"] == "Loaded MC dataset from FITS."

def test_short_history(self, dataarray_cut: xr.DataArray) -> None:
"""Test for S.short_history."""
history = dataarray_cut.S.short_history()
assert history[0] == "load_MC"
assert history[1] == "filesystem"


def test_find(dataarray_cut: xr.DataArray) -> None:
"""Test for S.find."""
Expand Down

0 comments on commit ba61469

Please sign in to comment.