Skip to content

Commit

Permalink
Periodic counter now starts at one instead of zero
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed May 16, 2017
1 parent 395717a commit fa983f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions holoviews/core/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,9 @@ def __call__(self, period, count, param_fn=None, timeout=None, block=True):
If param_fn is not specified, the event method is called without
arguments. If it is specified, it must be a callable accepting a
single argument (the iteration count) that returns a dictionary
of the new stream values to be passed to the event method.
single argument (the iteration count, starting at 1) that
returns a dictionary of the new stream values to be passed to
the event method.
"""

if self.instance is not None and not self.instance.completed:
Expand Down
2 changes: 1 addition & 1 deletion holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def run(self):
time.sleep(self.period)
else:
self._completed.wait(self.period)
self.callback(self.counter)
self.counter += 1
self.callback(self.counter)

if self.timeout is not None:
dt = (time.time() - self._start_time)
Expand Down
5 changes: 2 additions & 3 deletions tests/testdynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ def callback(x): return Curve([1,2,3])
# Add stream subscriber mocking plot
xval.add_subscriber(lambda **kwargs: dmap[()])
dmap.periodic(0.01, 100, param_fn=lambda i: {'x':i})
self.assertEqual(xval.x, 99)
self.assertEqual(xval.x, 100)

def test_periodic_param_fn_non_blocking(self):
def callback(x): return Curve([1,2,3])
Expand All @@ -602,7 +602,7 @@ def callback(x): return Curve([1,2,3])
if dmap.periodic.instance.completed:
break
dmap.periodic.stop()
self.assertEqual(xval.x, 999)
self.assertEqual(xval.x, 1000)

def test_periodic_param_fn_blocking_period(self):
def callback(x):
Expand All @@ -614,7 +614,6 @@ def callback(x):
start = time.time()
dmap.periodic(0.5, 10, param_fn=lambda i: {'x':i}, block=True)
end = time.time()
print end-start
self.assertEqual((end - start) > 5, True)


Expand Down

0 comments on commit fa983f6

Please sign in to comment.