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

@philippjfr 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.

@jlstevens
Copy link
Contributor

@jlstevens 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...

Loading

@@ -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

@jlstevens jlstevens Oct 10, 2016

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...

Loading

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

@jlstevens jlstevens Oct 10, 2016

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!

Loading

@jlstevens
Copy link
Contributor

@jlstevens 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...

Loading

@philippjfr
Copy link
Member Author

@philippjfr philippjfr commented Oct 10, 2016

Once the tests pass let's merge it.

Loading

@jlstevens
Copy link
Contributor

@jlstevens jlstevens commented Oct 10, 2016

Tests passed. Merging.

Loading

@jlstevens jlstevens merged commit 3f9842d into master Oct 10, 2016
4 checks passed
Loading
@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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants