
All, Currently, np.unique1d uses np.asarray to ensure the input is an array. The problem is that np.asarray transforms a MaskedArray into a regular ndarray, the missing information is lost and the result is not correct. If we used np.asanyarray instead, subclasses are recognized properly, the mask is recognized by argsort and the result correct. Is there a reason why we use np.asarray instead of np.asanyarray ? Thanks a lot in advance, P.

On Sun, Jan 4, 2009 at 15:44, Pierre GM <pgmdevlist@gmail.com> wrote:
All, Currently, np.unique1d uses np.asarray to ensure the input is an array. The problem is that np.asarray transforms a MaskedArray into a regular ndarray, the missing information is lost and the result is not correct. If we used np.asanyarray instead, subclasses are recognized properly, the mask is recognized by argsort and the result correct. Is there a reason why we use np.asarray instead of np.asanyarray ?
Probably not. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco

On Jan 4, 2009, at 4:47 PM, Robert Kern wrote:
On Sun, Jan 4, 2009 at 15:44, Pierre GM <pgmdevlist@gmail.com> wrote:
If we used np.asanyarray instead, subclasses are recognized properly, the mask is recognized by argsort and the result correct. Is there a reason why we use np.asarray instead of np.asanyarray ?
Probably not.
So there wouldn't be any objections to make the switch ? We can wait a couple of days if anybody has a pb with that...

Pierre GM wrote:
On Jan 4, 2009, at 4:47 PM, Robert Kern wrote:
On Sun, Jan 4, 2009 at 15:44, Pierre GM <pgmdevlist@gmail.com> wrote:
If we used np.asanyarray instead, subclasses are recognized properly, the mask is recognized by argsort and the result correct. Is there a reason why we use np.asarray instead of np.asanyarray ? Probably not.
So there wouldn't be any objections to make the switch ? We can wait a couple of days if anybody has a pb with that...
There are probably other functions in arraysetops that could be fixed easily to work with masked arrays, feel free to do it if you like. I have never worked with the masked arrays, so the np.asarray problem had not come to my mind. Also, if you change np.asarray to np.asanyarray, add a corresponding test emplying the masked arrays to test_arraysetops.py, please. cheers & thanks, r.
participants (3)
-
Pierre GM
-
Robert Cimrman
-
Robert Kern