Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
BF: for degenerate polygons, add CLOSEPOLY vertex#17982
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
BF: for degenerate polygons, add CLOSEPOLY vertex#17982
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
33cc440
to787bf03
CompareThere 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.
Add a test?
787bf03
toe551a27
Compare
Couldn't decide what to test initially. Settled on testing that for a single point (x, y), the extents of a degenerate polygon with only that point as its vertices has the extents |
I'm sure this was covered in the other PR, but what happens if x=np.Nan? |
tl;dr: NaN works. The So |
CI fail is due to "error allocating resources" on our Mac box? |
... the mac CI on azure seems to have issues |
lib/matplotlib/patches.py Outdated
if self._closed: | ||
iflen(xy) and (xy[0] != xy[-1]).any(): | ||
ifN == 1 or N > 1 and (xy[0] != xy[-1]).any(): |
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.
Could you add a quick comment about theif
statements you've changed just to say what they're doing? And maybenverts
is a better variable name than justN
?
brunobeltranJul 21, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
I was reticent to add these comments, because technically the checks here are very brittle as-written, so I didn't want to give people the impression this is something which is okay to do in other code.
The checks are bad because we don't guarantee anything about the coordinates of a CLOSEPOLY vertex, but this code uses the assumption that these vertices will "correctly" match the start point of the curve.
In particular, both Python (e.g.Path.iter_bezier
) and C++ code (i.e. handlers foragg:path_flags_close
) actively ignore this vertex's value, because it's known to hold "trash" sometimes, especially after cleaning NaN arrays, etc (weird stuff like#17885 and#17914).
But, I added comments that make it more clear what the if statements arenominally doing, since you think it's a good idea. I personally likeN
since it matches what all thePolygon
docstrings use, but I agree thatnverts
is easier to read if you're skimming the code only.
e551a27
to1a1c288
Compare1a1c288
to0d5c018
Compare…982-on-v3.3.xBackport PR#17982 on branch v3.3.x (BF: for degenerate polygons, add CLOSEPOLY vertex)
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
Fixes#17975. New
iter_bezier
code exposed an existing bug inpatches.Polygon.set_xy
.The check
xy[0] != xy[-1]
was meant to check if the user had already included an extraCLOSEPOLY
vertex for us in the list of vertices (shape(xy) = (N, 2)
).But for single-vertex (degenerate)Polygon
s, it produced a false positive (sincexy[0] == xy[-1]
by definition), leading to malformedPath
s that look like:PR Checklist