Skip to content
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
Merged

Conversation

philippjfr
Copy link
Member

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 type: bug Something isn't correct or isn't working label Oct 10, 2016
@jlstevens
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just like the price stream example notebook in contrib!

@jlstevens
Copy link
Contributor

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

@philippjfr
Copy link
Member Author

Once the tests pass let's merge it.

@jlstevens
Copy link
Contributor

Tests passed. Merging.

@jlstevens jlstevens merged commit 3f9842d into master Oct 10, 2016
@philippjfr philippjfr deleted the get_dynamic_item_fix branch October 14, 2016 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants