| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Add a test?
Sorry, something went wrong.
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 Bbox([[x, y], [x, y]]), which is the behavior where we actually differ from the (buggy) 3.2 behavior. |
Sorry, something went wrong.
|
I'm sure this was covered in the other PR, but what happens if x=np.Nan? |
Sorry, something went wrong.
|
tl;dr: NaN works. The Polygon class doesn't complain about NaN's or clean them explicitly (currently. You might argue that it should). So Polygon([[np.nan, 0]]) creates a path that would be correct if there were no NaN's there: Path([[np.nan, 0], [np.nan, 0]], [MOVETO, CLOSEPOLY]). The new Path.get_extents blindly adds all possible extremal values to a Bbox.null() (which in this case are all NaN). Adding a NaN to a Bbox is a no-op, (the call chain ends in _path.update_path_extents, which works on a PathNaNRemover<agg:conv_transform<PathIterator>>), so the Bbox stays null, correctly indicating there are no non-NaN points in the polygon. |
Sorry, something went wrong.
|
CI fail is due to "error allocating resources" on our Mac box? |
Sorry, something went wrong.
|
... the mac CI on azure seems to have issues |
Sorry, something went wrong.
| N, _ = xy.shape | ||
| if self._closed: | ||
| if len(xy) and (xy[0] != xy[-1]).any(): | ||
| if N == 1 or N > 1 and (xy[0] != xy[-1]).any(): |
There was a problem hiding this comment.
Could you add a quick comment about the if statements you've changed just to say what they're doing? And maybe nverts is a better variable name than just N?
Sorry, something went wrong.
There was a problem hiding this comment.
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 for agg: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 are nominally doing, since you think it's a good idea. I personally like N since it matches what all the Polygon docstrings use, but I agree that nverts is easier to read if you're skimming the code only.
Sorry, something went wrong.
…982-on-v3.3.x Backport PR #17982 on branch v3.3.x (BF: for degenerate polygons, add CLOSEPOLY vertex)
| Back | FazBrowse Home | New Git URL |
PR Summary
Fixes #17975. New iter_bezier code exposed an existing bug in patches.Polygon.set_xy.
The check xy[0] != xy[-1] was meant to check if the user had already included an extra CLOSEPOLY vertex for us in the list of vertices (shape(xy) = (N, 2)). But for single-vertex (degenerate) Polygons, it produced a false positive (since xy[0] == xy[-1] by definition), leading to malformed Paths that look like:
PR Checklist