FIX: fastpath clipped artists#14445
Conversation
| """ | ||
| return Bbox([[0, 0], [0, 0]]) | ||
|
|
||
| def get_clip_bbox_extents(self): |
There was a problem hiding this comment.
Perhaps call this get_clip_extents? (otherwise it's not clear whether it's just the extents of the clip box or of the intersection of the clip_box and the clip_path)
There was a problem hiding this comment.
How about get_clip_bbox. I guess this should also be private, just so we don't have to worry about changing it.
There was a problem hiding this comment.
+1 for private as usual ;)
get_clip_bbox sounds too close to get_clip_box to me...
There was a problem hiding this comment.
OK, private and _get_clipping_extent_bbox was what I decided on. It is an extent (rather than the actual clip path) and it returns a Bbox.
f6dbc7f to
c4c7473
Compare
|
Trying to sneak in to 3.1.1 since this can be a pretty big speedup for some cases. But not Release Critical if it doesn't get in... |
|
|
||
| def _get_clipping_extent_bbox(self): | ||
| """ | ||
| Return the intersection of the clip_path and clip_box for this |
There was a problem hiding this comment.
"Return the extents of the intersection..."
| def _get_clipping_extent_bbox(self): | ||
| """ | ||
| Return the intersection of the clip_path and clip_box for this | ||
| artist. Returns None if both of these are None, or ``get_clip_on`` |
| if clip_extent is not None: | ||
| clip_extent = mtransforms.Bbox.intersection(clip_extent, | ||
| axbbox) | ||
| inside_axes = np.all(clip_extent.extents == axbbox.extents) |
There was a problem hiding this comment.
if not inside_axes: continue
and then below you don't need to re-check for Noneness of clip_extent.
There was a problem hiding this comment.
Refactored to make this cleaner...
There was a problem hiding this comment.
... though I have a mild aversion to continue. Somewhere I got accustomed to continue being bad style...
anntzer
left a comment
There was a problem hiding this comment.
Only minor style points, but overall looks nice.
c4c7473 to
1f889a8
Compare
1f889a8 to
2eb6772
Compare
|
Thanks @jklymak ! |
…445-on-v3.1.x Backport PR #14445 on branch v3.1.x (FIX: fastpath clipped artists)
PR Summary
In 3.x
ax.get_tightbbox()started to include all artists on the axes when it was called. This is an expected performance hit. @tacaswell suggested that perhaps if the artist is clipped by the axes patch this is not necessary.The change here implements that solution - if the artist is clipped and the clip path is contained in the axes clip path, then
artist.get_tightbbox()is no longer called for that artist.Example:
Old:
18.68
New:
0.4187
PR Checklist