Skip to content

Commit

Permalink
updated naming and api of AdapterProgress
Browse files Browse the repository at this point in the history
  • Loading branch information
Helveg committed Jan 25, 2024
1 parent bddbe57 commit a562493
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions bsb/simulation/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@

class AdapterProgress:
def __init__(self, duration):
self._progdur = duration
self._progstart = self._last_progtic = time()
self._progtics = 0
self._duration = duration
self._start = self._last_tick = time()
self._ticks = 0

def tick(self, step):
"""
Report simulation progress.
"""
now = time()
tic = now - self._last_progtic
self._progtics += 1
el = now - self._progstart
tic = now - self._last_tick
self._ticks += 1
el = now - self._start
progress = types.SimpleNamespace(
progression=step, duration=self._progdur, time=time(), tick=tic, elapsed=el
progression=step, duration=self._duration, time=time(), tick=tic, elapsed=el
)
self._last_progtic = now
self._last_tick = now
return progress

def steps(self, duration, step=1):
steps = itertools.chain(np.arange(0, duration), (duration,))
def steps(self, step=1):
steps = itertools.chain(np.arange(0, self._duration, step), (self._duration,))
a, b = itertools.tee(steps)
next(b, None)
yield from zip(a, b)
Expand Down

0 comments on commit a562493

Please sign in to comment.