From fa983f6bdf53035ebc1df9c3a410314c5fac163c Mon Sep 17 00:00:00 2001 From: jlstevens Date: Tue, 16 May 2017 02:03:03 +0100 Subject: [PATCH] Periodic counter now starts at one instead of zero --- holoviews/core/spaces.py | 5 +++-- holoviews/core/util.py | 2 +- tests/testdynamic.py | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/holoviews/core/spaces.py b/holoviews/core/spaces.py index 3a3a2adcd3..bba2f4dc16 100644 --- a/holoviews/core/spaces.py +++ b/holoviews/core/spaces.py @@ -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: diff --git a/holoviews/core/util.py b/holoviews/core/util.py index a642bf291d..bb4e9bf23e 100644 --- a/holoviews/core/util.py +++ b/holoviews/core/util.py @@ -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) diff --git a/tests/testdynamic.py b/tests/testdynamic.py index 4efa7e29a8..da557a7113 100644 --- a/tests/testdynamic.py +++ b/tests/testdynamic.py @@ -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]) @@ -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): @@ -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)