Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Use masked stack to preserve mask info#24732
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
oscargus commentedDec 15, 2022
Can you please add a test (like just copy the one in#24545)? (This seems to be the correct fix, although my knowledge of masked is very limited...) |
rcomer commentedDec 15, 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.
Nice detective work@chahak13! Could you add a test that would have failed without this change? Maybe adapt the example from#24545 into animage test. [Edit: cross-post with@oscargus, but it is good to see we agreed!] |
oscargus commentedDec 15, 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.
Btw, the same thing cannot happen here as well? matplotlib/lib/matplotlib/collections.py Line 322 incc85fb6
But maybe paths cannot have units or masked arrays to start with? |
oscargus commentedDec 15, 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.
It may be that this is actually better solved in matplotlib/lib/matplotlib/collections.py Lines 548 to 550 incc85fb6
which would then remove the need for an additional unit conversion etc. Anyway, probably better to get this in and then spend some effort trying to make it more unified. The risk is that it will take quite a bit of time to untangle everything... |
chahak13 commentedDec 15, 2022
@oscargus good point. This might actually be a more deep-rooted issue. I checked |
chahak13 commentedDec 15, 2022
I've added a test and baseline images for this for now. This should resolve the current issue but I'll try to dig into the usage of masked data later. Let me know if there's something missing! |
oscargus commentedDec 15, 2022
Thanks! Maybe, for the sake of it, add a (It may be enough to only have one of the format, e.g., png, but that would require a rebase with force push as the cleanliness test will become unhappy otherwise.) |
oscargus commentedDec 15, 2022
Oh, and if there is a way to actually get a masked Path with units to test with that would be great, but shouldn't be a show stopper for now. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
chahak13 commentedDec 15, 2022
@oscargus@rcomer, need advice. I was working on the TLDR: matplotlib/lib/matplotlib/axis.py Lines 1731 to 1740 incc85fb6
The reason the fix that I made worked for this case is that the mask was on a numeric field. For all the non-number types, |
oscargus commentedDec 15, 2022
I'd say skip the equal test then for now. It may be a deep rabbit hole... I'll add a comment to#24733 pointing this out. Probably the right thing is to support masked arrays in |
chahak13 commentedDec 15, 2022
Understood, thanks. I'll resolve the 2 comments on the review then. |
6c59932 to9001a20Comparechahak13 commentedDec 15, 2022
That should do it. Let me know if there's anything needed! |
rcomer 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.
Thanks@chahak13, this looks good to me (assuming CI passes, but I can't see a reason it wouldn't).
oscargus commentedDec 15, 2022
Thanks! FYI, it wasn't that tricky to get masked dates to pass:#24734 But we can add the image equal test when digging into the other aspects later. |
oscargus 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.
Agreed! Looks good! Anyone can merge on green.
chahak13 commentedDec 15, 2022
Yes, it was pretty straight forward! I had the fix on my local machine but just wasn't sure if we wanted to include that in this or would that be out of scope for this particular PR. Thanks though! |
oscargus commentedDec 15, 2022
Ahh, sorry about that then. Just didn't want you to go down a potential rabbit hole by encouraging it... |
…732-on-v3.6.xBackport PR#24732 on branch v3.6.x (Use masked stack to preserve mask info)
PR Summary
As pointed out in#24545 ,
scatterwas not masking datetime correctly. This issue would be true for any data with units because of the following linesmatplotlib/lib/matplotlib/collections.py
Lines 323 to 325 incc85fb6
Whenever
self.have_units()wasTrue, it would usenp.column_stackinstead ofnp.ma.column_stackwhich would lead to the loss of mask information. Changing that to the masked versionresolves#24545 .PR Checklist
Documentation and Tests
pytestpasses)Release Notes
.. versionadded::directive in the docstring and documented indoc/users/next_whats_new/.. versionchanged::directive in the docstring and documented indoc/api/next_api_changes/next_whats_new/README.rstornext_api_changes/README.rst