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
Use set_bounds
rather than setting low
and high
individually for Zoom.
#233
Conversation
x_mapper.range.high = self.next[1] | ||
y_mapper.range.low = self.next[2] | ||
y_mapper.range.high = self.next[3] | ||
x_mapper.range.set_bound(low=self.next[0], high=self.next[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should these be set_bounds
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm yes! Sorry, I thought I had tested it but it looks like I don't know how to trigger this.
Are there any tests that cover this refactoring? |
If you are doing this, it may be worth looking for places where the mapper high and low are set individually as well, eg. https://github.com/enthought/chaco/blob/master/chaco/data_view.py#L306 I had considered fixing those in an earlier PR, but it seemed tangential. |
The example you give is changing a |
It has a |
Got it |
Use `set_bounds` rather than setting `low` and `high` individually for Zoom.
This reduces the number of event fired around drastically.
Compare this profile snapshot before the change:
and after:
Notice that the time per-call of
_do_zoom
is reduced from0.00209
to0.00122
, but especially that_set_low_setting
and_set_high_setting
are called once perzoom_in
/zoom_out
, reducing the potential for trouble if anything depends on the bounds of the plot.