BF: ignore CLOSEPOLY after NaN in PathNanRemover#17885
BF: ignore CLOSEPOLY after NaN in PathNanRemover#17885QuLogic merged 2 commits intomatplotlib:masterfrom
Conversation
|
I think we ignore the point entirely for p = Path(
[[0, 0], [np.nan, np.nan]],
[1, 79]) |
Great question. It leaves it as-is. (Same as previous behavior). >>> p.cleaned(remove_nans=True)
Path(array([[ 0., 0.],
[nan, nan],
[ 0., 0.]]), array([ 1, 79, 0], dtype=uint8))I think this makes sense because
So this PR only changes the behavior when leaving a |
|
I'm aware that this doesn't play well with >>> p.cleaned(remove_nans=True, simplify=True)
Path(array([[ 0., 0.],
[nan, nan],
[nan, nan],
[ 0., 0.]]), array([1, 2, 2, 0], dtype=uint8))but this is also existing behavior, and I haven't taken the time to grok the full |
|
Per the call, added tests that check the "optimized" code path (i.e. empty |
e90850f to
b95ce02
Compare
b95ce02 to
e216e59
Compare
QuLogic
left a comment
There was a problem hiding this comment.
I pushed a small whitespace fix.
…885-on-v3.3.x Backport PR #17885 on branch v3.3.x (BF: ignore CLOSEPOLY after NaN in PathNanRemover)
PR Summary
Fixes #17868.
In short, the current
PathNanRemoveralways keepsCLOSEPOLY"vertices" around, even if they contain NaN. This is arguably okay (since it is documented in comments that the values ofCLOSEPOLYvertices are ignored). However, because of this, if a CLOSEPOLY occurs before any non-NaN segments of a Path are encountered, thenPathNanRemover(and, by proxy,Path.cleaned(remove_nans=True)will return a malformedPaththat starts with aCLOSEPOLY.Current behavior:
New behavior
PR Checklist