Skip to content

Commit 2fc1634

Browse files
authored
Fix TimeSeries parameters resetting across simulations. (#486)
1 parent 565c4e1 commit 2fc1634

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/scenic/core/external_params.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,18 @@ def extractOutput(self, value):
381381
class TimeSeriesParameter:
382382
def __init__(self, callback):
383383
self._callback = callback
384+
self._lastSimulation = None
384385
self._lastTime = -1
385386

386387
def getSample(self):
387388
import scenic.syntax.veneer as veneer
388389

389390
assert veneer.currentSimulation is not None
390391

392+
if self._lastSimulation is not veneer.currentSimulation:
393+
self._lastSimulation = veneer.currentSimulation
394+
self._lastTime = -1
395+
391396
if veneer.currentSimulation.currentTime <= self._lastTime:
392397
raise RuntimeError(
393398
"Attempted `getSample` for a TimeSeries external parameter twice in one timestep."

0 commit comments

Comments
 (0)