Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Fixed bug in find_nearest_contour#22767
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
Fixed bug in find_nearest_contour#22767
Uh oh!
There was an error while loading.Please reload this page.
Conversation
c51aeef to55d98a7Compareoscargus commentedApr 4, 2022
Power cycling to trigger the tests. |
andrew-fennell commentedApr 7, 2022
I think this PR is ready for further review. Let me know if any changes need to be made to the testing. |
lib/matplotlib/contour.py Outdated
| ifindicesisNone: | ||
| indices=range(len(self.levels)) | ||
| indices=range(len(self.layers)) |
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 have a slight preference to change this to
| indices=range(len(self.layers)) | |
| indices=range(len(self.collections)) |
as that is the data structure that we need to match?
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 think this change makes sense. I outlined some issues below that I'd like you to look at.
tacaswell commentedApr 8, 2022
I have not chased this through enough to answer this my self, but is this method implemented in a way that makes sense for filled contours? With line contours you know that each path is at the same level and lines never intersect. With a filled contour the whole patch is "at the same level" with discontinuities at the boundaries (that is there are two patches that share and edge that are different values). In the case of filled shouldn't we be saying "which collection does this fall in?" instead? |
andrew-fennell commentedApr 8, 2022 • 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.
55d98a7 to6eea6e6Compareandrew-fennell commentedApr 8, 2022
If this function should only support #22762 highlights that currently, when the function is called on |
QuLogic commentedApr 8, 2022
Sorry, didn't see@tacaswell's additional questions; I won't merge until he's satisfied with the answers. |
jklymak commentedApr 8, 2022
I am not sure what use there is in choosing the nearest "contour" on a filled contour. My tendency would be to raise on contourf collections and if users need to know the "nearest contour" they can make an unfilled contour to go with the filled one (perhaps hiding it if they don't want itvnisually there). |
tacaswell left a comment
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.
The consensus of the discussion is that the correct fix here is to :
- document that this only works on unfilled contours
- make it raise a better error on filled contours
andrew-fennell commentedApr 9, 2022
I agree with the consensus! Thanks for all of the input. I will make these changes soon. I need to get through a few other things first. |
ec55df9 tof8a80f7CompareUh oh!
There was an error while loading.Please reload this page.
f8a80f7 to4a47543CompareCompletely different approach now.
QuLogic commentedApr 12, 2022
@meeseeksdev backport to v3.5.x |
…767-on-v3.5.xBackport PR#22767 on branch v3.5.x (Fixed bug in find_nearest_contour)



Uh oh!
There was an error while loading.Please reload this page.
PR Summary
The find_nearest_contour function was defined incorrectly. I fixed the bug and added a simple test, based on the original issues test.
Thank you@jhelmboldt for finding this issue and offering a solution to it.
Closes#22762
PR Checklist
Tests and Styling
pytestpasses).flake8-docstringsand runflake8 --docstring-convention=all).