-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Simplify some patches path definitions. #24304
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
Conversation
arc.codes, arc.codes, [connector, Path.CLOSEPOLY]]) | ||
c[len(arc.codes)] = connector | ||
v = np.concatenate([v1, v2, [(0, 0)]]) | ||
c = [*arc.codes, connector, *arc.codes[1:], Path.CLOSEPOLY] |
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.
In the case of a full anuulus will this result in an extra line connecting the inner and outer rings?
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.
No, because for full annuli(?) the connector is MOVETO, which defines a new initial point for a subpath, and CLOSEPOLY closes to that initial point. You can check with e.g.
from pylab import *; w = mpl.patches.Wedge((.5, .5), .3, 0, 360, width=.1, linewidth=5, facecolor="none", edgecolor="k"); figure().add_subplot(aspect=1).add_artist(w)
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.
Shouldn't the outer arc be CLOSEPOLY
'd as well, then? I agree the new stuff won't break it, but that seems the semantically correct thing to do (and the existing code didn't do it correctly.)
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.
Fair, but I think that's something that should be fixed at the level of Path.arc(), not here.
- When a Path ends with a CLOSEPOLY, it is not necessary to put a LINETO to the closing position before it (in fact that can result in an incorrect line join at that position), and the xy position associated with the CLOSEPOLY can just be (0, 0), as it is irrelevant. - For defining the codes arrays, for short paths (such as the patch shapes here), one can just use list unpacking for shorter definitions. - Rename the _path and _fillable lists in ArrowStyle to plural names. - Rely on the default tolerance of split_bezier_intersecting_with_closedpath (which is 0.01) rather than re-specifying the same magic value everywhere. - Remove inapplicable comment re: make_compound_path_from_polys (which only applies to polygons all of with the same number of sides, which is not the case when clipping to a bbox).
Also removed an outdated/inapplicable comment while we're at it. |
split_bezier_intersecting_with_closedpath (which is 0.01) rather than
re-specifying the same magic value everywhere.
only applies to polygons all of with the same number of sides, which
is not the case when clipping to a bbox).
PR Summary
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst