Skip to content

Commit

Permalink
Manual way to drive FPSHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Shmuma committed Jul 31, 2019
1 parent dbca226 commit 844b3cc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ptan/ignite.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,18 @@ def __init__(self, fps_mul: float = 1.0, fps_smooth_alpha: float = 0.98):
self._started_ts = time.time()
self._fps_smooth_alpha = fps_smooth_alpha

def attach(self, engine: Engine):
self._timer.attach(engine, step=Events.ITERATION_COMPLETED)
def attach(self, engine: Engine, manual_step: bool = False):
self._timer.attach(engine, step=None if manual_step else Events.ITERATION_COMPLETED)
engine.add_event_handler(EpisodeEvents.EPISODE_COMPLETED, self)

def step(self):
"""
If manual_step=True on attach(), this method should be used every time we've communicated with environment
to get proper FPS
:return:
"""
self._timer.step()

def __call__(self, engine: Engine):
t_val = self._timer.value()
if engine.state.iteration > 1:
Expand Down

0 comments on commit 844b3cc

Please sign in to comment.