Skip to content

Commit 450f8b2

Browse files
committed
StepSnapH5 only built if timeh5 exists
StepSnapH5 also now directly holds the path to timeh5 instead of the entire `sdat` instance.
1 parent f05cb3f commit 450f8b2

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/stagpy/_caching.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
if typing.TYPE_CHECKING:
1414
from collections.abc import Mapping
15+
from pathlib import Path
1516

1617
from .datatypes import Field
1718
from .stagyydata import StagyyData
@@ -89,15 +90,14 @@ class StepSnapInfo:
8990

9091
@dataclass(frozen=True)
9192
class StepSnapH5(StepSnap):
92-
sdat: StagyyData
93+
timeh5: Path
9394

9495
@cached_property
9596
def _info(self) -> StepSnapInfo:
9697
isnap = -1
9798
step_to_snap = {}
9899
snap_to_step = {}
99-
timeh5 = self.sdat.par.h5_output("time_botT.h5")
100-
for isnap, istep in parsers.h5.extras.isnap_istep(timeh5):
100+
for isnap, istep in parsers.h5.extras.isnap_istep(self.timeh5):
101101
step_to_snap[istep] = isnap
102102
snap_to_step[isnap] = istep
103103
return StepSnapInfo(

src/stagpy/stagyydata.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ def _field_cache(self) -> FieldCache:
799799

800800
@cached_property
801801
def _step_snap(self) -> StepSnap:
802-
if self.hdf5 is not None:
803-
return StepSnapH5(sdat=self)
802+
timeh5 = self.par.h5_output("time_botT.h5")
803+
if timeh5.is_file():
804+
return StepSnapH5(timeh5=timeh5)
804805
return StepSnapLegacy(sdat=self)

0 commit comments

Comments
 (0)