Skip to content

Conversation

@abalkin
Copy link
Contributor

@abalkin abalkin commented Nov 12, 2013

...rect type.

If x is of type MaskedArray for ma.asarray(x) or any subtype of
MaskedArray for ma.asanyarray(x), these functions will simply return x.
This makes them consistent with their numpy counterparts.

Closes gh-4043.

…correct type.

If x is of type MaskedArray for ma.asarray(x) or any subtype of
MaskedArray for ma.asanyarray(x), these functions will simply return x.
This makes them consistent with their numpy counterparts.

Closes numpygh-4043.
@charris
Copy link
Member

charris commented Nov 14, 2013

@abalkin Test failures are universal. You should be able to check at home and fix them up.

Previous implementation relied on ma.asarray() to always create
a new object.

See numpygh-4043.
@abalkin
Copy link
Contributor Author

abalkin commented Feb 24, 2014

Travis is green now. a49c279 illustrates possible backward-compatibility problems.

@charris
Copy link
Member

charris commented Feb 25, 2014

The documentation of the function needs fixing/updating. It isn't clear to me that the function should always return a new array, doing so may break current code. What is the argument for this change? That argument should also be in the commit message.

@abalkin
Copy link
Contributor Author

abalkin commented Feb 25, 2014

@charris - please see discussion at gh-4039. In short, ma.MAskedArray constructor is very slow and traditionally asarray functions would pass through objects of the correct type. This is what both numpy.asarray and numpy.oldnumeric.ma.asarray do.

@seberg
Copy link
Member

seberg commented Feb 26, 2014

As such, I think it would be correct to just pass through a masked array. But maybe we should ping the mailing list about it. It could potentially create some backward compatibility problems, afterall. Needs a prominent warning in the release notes in any case.

@charris
Copy link
Member

charris commented Mar 23, 2014

Looks like it should already not be making a copy unless needed

return masked_array(a, dtype=dtype, copy=False, keep_mask=True, subok=False)

If it is slow, or not working correctly, maybe masked_array needs some work.

@charris
Copy link
Member

charris commented Mar 27, 2014

LGTM, but I notice that ma.asarray has an order keyword which is not used, nor available in masked_array. Also, ma.asanyarray doesn't have an order keyword, but is documented as having one. Could you fix that up before this goes in?

@charris
Copy link
Member

charris commented Mar 27, 2014

Or rather, I'll put this in to encourage you ;) And then could you fix the documentation/functions?

charris added a commit that referenced this pull request Mar 27, 2014
ENH: ma.asarray() and ma.asanyarray() will pass through input of the cor...
@charris charris merged commit 46767a2 into numpy:master Mar 27, 2014
@abalkin abalkin deleted the gh-4043 branch March 28, 2014 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ma.asarray() should pass through objects of the right type

3 participants