-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix as_compatible_data for read-only np.ma.MaskedArray #7788
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
Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient. |
I've marked this by accident, sorry @maxhollmann. Let us know when you feel this is ready |
Hi @kmuehlbauer, no worries! It's in draft because can't figure out how to reproduce this bug for the tests. |
@maxhollmann I'll have a look into this, I think I've seen something like this some time ago. Maybe you can add the tests to the PR or as comment? This might get more attention and will really help to debug. |
0979e27
to
340e14b
Compare
@kmuehlbauer Sure, I pushed the test as I was hoping it would work. |
@maxhollmann I've checked and memory served well, the following issue might be related: #2377. It looks like your use-case is at least connected to @gerritholl's. It would be great if you could add your original use case (as MCVE, if possible) to get more details. A special case (masked integer arrays) is discussed in #3955. As this might give additional information, it might not exactly fit your problem. |
@kmuehlbauer For some reason I can't reproduce it anymore. I'll monitor whether it occurs again in the original situation and close this otherwise after some time. |
340e14b
to
806c3f7
Compare
@kmuehlbauer Okay, I got it. It only seems to happen with float arrays. I adjusted the test, and it now fails without the fix. Only tangentially related to this PR, but I noticed that |
@kmuehlbauer Do you need any adjustments to merge this? |
806c3f7
to
9cd0fb3
Compare
@maxhollmann We might get at least some more views on this. There have been discussions on handling masked arrays and we should make sure this is exactly the solution we want to have. @dcherian This changes |
@maxhollmann I'm sorry, I'm still finding my way into Xarray. I've taken a closer look at #2377, especially #2377 (comment). There @shoyer suggested to just use: data = duck_array_ops.where_method(data, ~mask, fill_value) instead of data[mask] = fill_value I've checked and it works nicely with your test. That way we would get away without the flags test and the special handling will take place in duck_array_ops. Would be great if someone can double check. |
I defer to @shoyer, the solution with |
9cd0fb3
to
c381dff
Compare
I like it, solves the concern in my previous comment as well. Updated the branch. |
Thanks @maxhollmann can you add a note to |
c381dff
to
84680ae
Compare
@dcherian Sure, done :) |
Thanks @maxhollmann I pushed a test for #2377. I see this is your first contribution to Xarray. Welcome! #1792 would be a nice contribution if you're looking for more to do ;) |
* Fix as_compatible_data for non-writeable float MaskedArray * Add test for pydata#2377 --------- Co-authored-by: dcherian <[email protected]>
whats-new.rst
api.rst