Repository navigation
Don't reset the fill_value of a MaskedArray when calling view() with no dtype - #2703
Conversation
|
This change makes sense to me, the original code doesn't. It was done on purpose though. I would propose to also add a |
…ehavior in the docstring.
…value to set the fill value, rather than _fill_value, since using fill_value takes care of setting _fill_value to an array.
|
@rgommers - I did this. I agree it's confusing that an int64 view of an int32 array does not preserve the fill_value, but I guess it's hard to make it automatic - would a string view of an int32 array set the fill value to a string representation of the previous string value? One thing we could do is emit a warning if the fill value gets reset. What do you think? I don't understand the two Travis failures - any ideas? |
There was a problem hiding this comment.
This doesn't look right, MaskedArray isn't a dtype.
|
Thanks the changes to |
|
I think with clear documentation like you added here the situation is OK, adding a warning could be annoying too. |
|
The Travis failures are unrelated, just ignore them. |
|
@rgommers - thanks for the review, I'll fix the minor issues. Now regarding and this does seem to be a legitimate use of so this is the first example of the second way. Technically, it should be I should add some tests explicitly specifying since this is acceptable behavior (for |
|
Hmm, never noticed that. Looks very ugly to me, and the So yes, then the test is OK. Documenting this better in both view() methods would be useful. |
|
@rgommers - ok, will do - should I include an improvement of the |
|
Adding it to this PR works for me. |
|
@rgommers - I've updated the docstrings, and added a few more tests. I also removed the print statements. Does it look ok now? (let me know if you have suggestions for tweaking the docstrings) |
|
This looks good to me now. I'll leave it open for a day or two in case someone else wants to comment. |
|
@rgommers - just wanted to check whether this can be merged? Thanks! |
Don't reset the fill_value of a MaskedArray when calling view() with no dtype
|
Yes, merged. Thanks @astrofrog |
This is a follow-up to:
http://mail.scipy.org/pipermail/numpy-discussion/2012-October/064291.html
Before this PR, the behavior of `MaskedArray.view()`` was:
And with this PR, it should be
Is there a reason for the original behavior? My guess is that if
dtypechanges, then it makes sense to reset thefill_valuesincefill_valueis type-dependent, but if thedtypestays the same, why reset thefill_value? Does the proposed behavior not make more sense?