New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensured dynamic callback is only called once #923

Merged
merged 2 commits into from Oct 10, 2016

Conversation

Projects
None yet
2 participants
@philippjfr
Member

philippjfr commented Oct 10, 2016

A bug in the get_dynamic_item function ended up making clones of DynamicMaps which resulted in the dynamic callback being called multiple times. This PR fixes this and adds unit tests for all three backends to ensure the plot is appropriately updated.

@philippjfr philippjfr added the bug label Oct 10, 2016

@jlstevens

This comment has been minimized.

Member

jlstevens commented Oct 10, 2016

Great!

The PR referenced above is an example notebook that needs this fix. It is also good to have those unit tests to make sure this bug is squashed for good. I'll now review the proposed changes...

@@ -967,7 +968,8 @@ def get_dynamic_item(map_obj, dimensions, key):
key_offset = max([key-map_obj.cache_size, 0])
key = map_obj.keys()[min([key-key_offset,
len(map_obj)-1])]
el = map_obj.map(lambda x: x[key], ['DynamicMap'])
el = map_obj.map(lambda x: x[key], ['DynamicMap'],
clone=False)

This comment has been minimized.

@jlstevens

jlstevens Oct 10, 2016

Member

Very minor nitpick: I don't see why clone=False needs to be on the next line in this case. Even if it is over 80 characters long it looks a bit weird...

def test_stream_callback_single_call(self):
def history_callback(x, history=deque(maxlen=10)):
history.append(x)
return Curve(list(history))

This comment has been minimized.

@jlstevens

jlstevens Oct 10, 2016

Member

Just like the price stream example notebook in contrib!

@jlstevens

This comment has been minimized.

Member

jlstevens commented Oct 10, 2016

The actual fix is very small and the tests looks good. Happy to merge if you feel it is ready...

@philippjfr

This comment has been minimized.

Member

philippjfr commented Oct 10, 2016

Once the tests pass let's merge it.

@jlstevens

This comment has been minimized.

Member

jlstevens commented Oct 10, 2016

Tests passed. Merging.

@jlstevens jlstevens merged commit 3f9842d into master Oct 10, 2016

4 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls First build on get_dynamic_item_fix at 73.047%
Details
s3-reference-data-cache Test data is cached.
Details

@philippjfr philippjfr deleted the get_dynamic_item_fix branch Oct 14, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment