File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -343,6 +343,8 @@ def __delitem__(self, name):
343343
344344 @crop
345345 def _header (self ) -> Optional [Dict [str , Any ]]:
346+ if self .step .isnap is None :
347+ return None
346348 binfiles = self .step .sdat ._binfiles_set (self .step .isnap )
347349 header = None
348350 if binfiles :
@@ -570,14 +572,16 @@ def timeinfo(self) -> Series:
570572 return info
571573
572574 @property
573- def time (self ) -> Optional [ float ] :
575+ def time (self ) -> float :
574576 """Time of this time step."""
575577 steptime = None
576578 try :
577579 steptime = self .timeinfo ['t' ]
578580 except error .MissingDataError :
579581 if self .isnap is not None :
580582 steptime = self .geom ._header .get ('ti_ad' )
583+ if steptime is None :
584+ raise error .NoTimeError (self )
581585 return steptime
582586
583587 @property
Original file line number Diff line number Diff line change @@ -48,6 +48,19 @@ def __init__(self, step: Step):
4848 super ().__init__ (f"no geometry info found for { step !r} " )
4949
5050
51+ class NoTimeError (StagpyError ):
52+ """Raised when no time can be found for a step.
53+
54+ Attributes:
55+ step: the :class:`~stagpy._step.Step` instance for which no geometry
56+ was found.
57+ """
58+
59+ def __init__ (self , step : Step ):
60+ self .step = step
61+ super ().__init__ (f"no time found for { step !r} " )
62+
63+
5164class NoRefstateError (StagpyError ):
5265 """Raised when no refstate output can be found.
5366
You can’t perform that action at this time.
0 commit comments