Skip to content

Commit a1929cf

Browse files
committed
New _Rprofs.stepstr property
1 parent 6057a61 commit a1929cf

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

stagpy/_step.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,11 @@ def __getitem__(self, name: str) -> Rprof:
460460

461461
return Rprof(rprof, rad, meta)
462462

463+
@property
464+
def stepstr(self) -> str:
465+
"""String representation of the parent :class:`Step`."""
466+
return str(self.step.istep)
467+
463468
@crop
464469
def centers(self) -> ndarray:
465470
"""Radial position of cell centers."""

stagpy/rprof.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ def plot_rprofs(rprofs: _Rprofs, names: str):
2121
names: profile names separated by ``-`` (figures), ``.`` (subplots) and
2222
``,`` (same subplot).
2323
"""
24-
try:
25-
stepstr = rprofs.steps.stepstr
26-
except AttributeError:
27-
stepstr = str(rprofs.step.istep)
24+
stepstr = rprofs.stepstr
2825
sdat = rprofs.step.sdat
2926

3027
for vfig in _helpers.list_of_vars(names):

stagpy/stagyydata.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ def __getitem__(self, name: str) -> Rprof:
334334
self._cached_data[name] = Rprof(rprof, rad, meta)
335335
return self._cached_data[name]
336336

337+
@property
338+
def stepstr(self) -> str:
339+
"""String representation of steps indices."""
340+
return self.steps.stepstr
341+
337342

338343
class _Steps:
339344
"""Collections of time steps.

0 commit comments

Comments
 (0)