-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
BUG: Fix implementation of _is_closed_polygon #17801
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
Waiting to see what kind of destruction this wreaks upon our suite of image tests... |
And for the historians, the previous implementation came in with 15a35dc and is the original, predating matplotlib 0.98.4. |
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.
Np.allclose?
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.
Np.allclose?
In Cartopy, we used |
Can we instead fix the contour generator to make it output exactly matching endpoints for contour lines? (AFAICT this is not intended as a general purpose function, but only to detect whether contour lines are closed) |
@anntzer This issue has held up a bugfix release for me for over a month (trying to get passing tests), so I'm not inclined to search for the pure solution right now, nor am I likely to have cycles any time soon to do so. Then again, I've now already monkey-patched this (internal 😬) function in my MetPy tests, so maybe it doesn't matter. For reference, here's a sample where it makes a difference--stock matplotlib: The change is in the closed 268 contour a third-ways from the right side of the image centered vertically, over Kansas and Oklahoma. I'll also note that this really only matters in practicality because the inline labelling algorithm takes a different approach for closed vs. open contours. In fact, that function is only used in the process of generating labels, nowhere else. |
It's a bad idea to use floating point equality to check if two points are equal. While not a huge difference, especially in the case of contour analysis, this was causing testing issues downstream. In one case this yielded different results for the same test on different OSes.
b10dae6
to
efa5b10
Compare
fair enough |
…801-on-v3.3.x Backport PR #17801 on branch v3.3.x (BUG: Fix implementation of _is_closed_polygon)
PR Summary
It's a bad idea to use floating point equality to check if two points are equal. While not a huge difference, especially in the case of contour analysis, this was causing testing issues downstream for MetPy. Specifically, I had one test that yielded different results on macOS vs. Linux/Windows, and this was the root cause. This change then slightly adjusted where a seemingly closed contour was labelled.
PR Checklist