Skip to content
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

Contourf bugfix in the presence of nans #4263

Merged
merged 5 commits into from
Aug 3, 2021
Merged

Contourf bugfix in the presence of nans #4263

merged 5 commits into from
Aug 3, 2021

Conversation

MHBalsmeier
Copy link
Contributor

🚀 Pull Request

Description

Fixes #4261 by using np.nanmax(cube.data) instead of cube.data.max().

@MHBalsmeier
Copy link
Contributor Author

I have checked, it does not break the problem mentioned in #4086.

@MHBalsmeier
Copy link
Contributor Author

I don't think I can get the performance test to pass.

@jamesp
Copy link
Member

jamesp commented Jul 29, 2021

Thanks for the PR fix @MHBalsmeier. Don't worry about the performance regression, that CI test is still work in progress, no reason this change should affect the benchmark that triggered. I've re-run the check.

@rcomer, do you want to just confirm you're happy with this fix? Seems like a reasonable change to me 👍

@rcomer
Copy link
Member

rcomer commented Jul 29, 2021

Yes thanks @MHBalsmeier for this. Nice detective work! I have to admit that nans had not even crossed my mind when I wrote the original fix. The proposed change looks good to me 👍

@MHBalsmeier
Copy link
Contributor Author

Okay I think this is ready for the final review.

@rcomer rcomer added this to the v3.1.0 milestone Jul 30, 2021
@rcomer
Copy link
Member

rcomer commented Jul 30, 2021

I’ve added this to the v3.1 project, as we clearly don’t want to introduce the bug in the next release!

My only question is whether this should have a new test, or whether that would be overkill for such a minor change. If we did want a test, I think it could follow the same pattern as the one I added at #4150. Just need to insert a nan somewhere in cube.data and choose the levels so that the loop is triggered. Then ax.collections should contain LineCollection instances, as they are added by contour. It might be enough to just check that the last element of ax.collections is a LineCollection.

What do you think @MHBalsmeier, @jamesp?

@MHBalsmeier
Copy link
Contributor Author

I am not sure if I get your point correctly because why would we introduce a bug with this ... I thought this solves #4086 as well as #4261.

As for the test, why not, but I never ran these tests and you seem to have the better idea of how to test this ...
I personally do not think this is really necessary.

@rcomer
Copy link
Member

rcomer commented Jul 30, 2021

@MHBalsmeier sorry I meant the bug that I introduced at #4150, that you are now fixing. We need to include your fix for the v3.1 release.

@MHBalsmeier
Copy link
Contributor Author

@rcomer okay I see

@rcomer
Copy link
Member

rcomer commented Aug 2, 2021

We have now added a test. I verified that the new test fails against main. The new setUp and tearDown ensure that the two tests on the class don't plot on the same figure/axes and interfere with each other's results.

The new failures appear to be because an external file has moved. I have opened #4266 to address that.

@jamesp
Copy link
Member

jamesp commented Aug 2, 2021

Thanks for fixing the doc failures @rcomer. @MHBalsmeier this just needs a rebase and should be good to go 👍

…bugfix

Pulling in the stuff that has been done on main.
@MHBalsmeier
Copy link
Contributor Author

Okay, lets see if I did that correctly.

Copy link
Member

@jamesp jamesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much @MHBalsmeier for sticking with it and getting this fix in, much appreciated!

@jamesp jamesp merged commit c17b7be into SciTools:main Aug 3, 2021
@MHBalsmeier MHBalsmeier deleted the nanplot_bugfix branch August 3, 2021 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Contourf plots look faulty if array contains nans
3 participants