Skip to content

Commit a4425b0

Browse files
committed
tighten some generic types
1 parent 4c03f76 commit a4425b0

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

src/stagpy/commands.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
from . import __version__, phyvars
1515
from ._helpers import baredoc, walk
1616
from .config import CONFIG_LOCAL, Config
17-
from .stagyydata import _sdat_from_conf
17+
from .stagyydata import StagyyData, _sdat_from_conf
1818

1919
if typing.TYPE_CHECKING:
2020
from collections.abc import Iterable, Mapping
2121
from typing import Callable
2222

2323
from loam.base import Section
2424

25-
from .datatypes import Varf, Varr, Vart
25+
from .datatypes import Field, Rprof, Tseries, Varf, Varr, Vart
26+
from .step import Step
2627

2728

2829
def info_cmd(conf: Config) -> None:
@@ -57,7 +58,10 @@ def info_cmd(conf: Config) -> None:
5758

5859
def _layout(
5960
dict_vars: Mapping[str, Varf | Varr | Vart],
60-
dict_vars_extra: Mapping[str, Callable],
61+
dict_vars_extra: Mapping[
62+
str,
63+
Callable[[Step], Field | Rprof] | Callable[[StagyyData], Tseries],
64+
],
6165
) -> Columns:
6266
"""Print nicely [(var, description)] from phyvars."""
6367
desc = [(v, m.description) for v, m in dict_vars.items()]

src/stagpy/field.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,9 @@ def cmd(conf: Config) -> None:
395395
plot_vec(axis, step, var[1], conf=conf)
396396
if conf.field.timelabel:
397397
time = step.timeinfo["t"]
398-
time = _helpers.scilabel(time)
398+
time_str = _helpers.scilabel(time)
399399
axes[0, 0].text(
400-
0.02, 1.02, f"$t={time}$", transform=axes[0, 0].transAxes
400+
0.02, 1.02, f"$t={time_str}$", transform=axes[0, 0].transAxes
401401
)
402402
oname = "_".join(chain.from_iterable(vfig))
403403
plt.tight_layout(w_pad=3)

src/stagpy/stagyydata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def isteps(self) -> NDArray[np.float64]:
224224
"""
225225
return self._tseries.index.values
226226

227-
def at_step(self, istep: int) -> Series:
227+
def at_step(self, istep: int) -> Series[np.float64]:
228228
"""Time series output for a given step."""
229229
return self._tseries.loc[istep] # type: ignore
230230

@@ -650,7 +650,7 @@ class StagyyData:
650650
logic.
651651
"""
652652

653-
path_hint: PathLike | str
653+
path_hint: PathLike[str] | str
654654
read_parameters_dat: bool = True
655655

656656
@property

src/stagpy/step.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ def geom(self) -> Geometry:
634634
return Geometry(self)
635635

636636
@property
637-
def timeinfo(self) -> Series:
637+
def timeinfo(self) -> Series[np.float64]:
638638
"""Time series data of the time step."""
639639
try:
640640
info = self.sdat.tseries.at_step(self.istep)

0 commit comments

Comments
 (0)