We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1a90c7e commit 8a12305Copy full SHA for 8a12305
src/stagpy/stagyydata.py
@@ -297,7 +297,6 @@ class Steps:
297
def __init__(self, sdat: StagyyData):
298
self.sdat = sdat
299
self._data: dict[int, Step] = {}
300
- self._len: int | None = None
301
302
def __repr__(self) -> str:
303
return f"{self.sdat!r}.steps"
@@ -336,9 +335,11 @@ def __delitem__(self, istep: int | None) -> None:
336
335
self.sdat._field_cache.evict_istep(istep)
337
del self._data[istep]
338
+ @cached_property
339
+ def _len(self) -> int:
340
+ return self.sdat.tseries.isteps[-1] + 1
341
+
342
def __len__(self) -> int:
- if self._len is None:
- self._len = self.sdat.tseries.isteps[-1] + 1
343
return self._len
344
345
def __iter__(self) -> Iterator[Step]:
0 commit comments