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
np.copy(masked array) has unexpected behavior #3474
Comments
Still open in 1.9-devel |
Not sure how to fix this without special casing masked arrays, though. |
Would changing the logic of np.copy to include
To:
If so, should subok should be a parameter to |
I'm not in favor of adding a
|
I would actually argue the opposite, since I think to most "copy" gives the impression that one would get something back that is, actually, a copy, and thus of the same type. I also see it as a small but useful contribution to make the whole of numpy more consistently able to deal with subclasses (just as I did earlier with Anyway, @jjhelmus, why not make a quick PR and see what others think? |
@shoyer: np.copy should probably go on your list of functions that need On Thu, Oct 15, 2015 at 7:00 AM, Marten van Kerkwijk <
Nathaniel J. Smith -- http://vorpus.org |
Yes, I would be +1 on making np.copy try calling the copy method on duck arrays. |
Still no reason not to support |
Created PR #6509 which adds a subok parameter to the function with a default value of False. I'm guessing this will open up some discussion on the topic. Not sure if this typically takes place on the PR, the issue, or the mailing list. |
Api discussion should be on the mailing list.
|
I'll send an email to the list on the topic tomorrow. |
....where "unexpected" means I didn't expect it. This may just be a documentation fix, or maybe I will be scolded for not realizing how
np.ma
works, but I don't think this behavior is appropriate:I would at least expect a warning, but would prefer to see, in order of preference:
np.copy(x)
returns a masked array (since x is a masked array)np.copy(x)
warns that it is unmasking the array, then returns the same array as abovenp.copy(x)
raises an exceptionnp.copy(x)
returns[1,1,nan,1,1]
(this is probably not ideal)The text was updated successfully, but these errors were encountered: