Sorry I didn't the docs very carefully. there is no doc for np.ma.argmax for indeed there is for np.ma.argmin
so it's an expected behavior rather than a bug. Let some heavy users to say their ideas. Practicaly, the returned value of 0 will be always confused with the values which are not masked but do have the minimum or maximum values at the 0 position over the specified axis. One way to walk around is: data_mask = np.ma.mean(axis=0).mask np.ma.masked_array(np.ma.argmax(data,axis=0), mask=data_mask) Chao On Tue, Jul 9, 2013 at 4:26 PM, Pierre Gerard-Marchant <[email protected] > wrote: > > On Jul 9, 2013, at 16:08 , Sebastian Berg <[email protected]> > wrote: > > > On Tue, 2013-07-09 at 15:14 +0200, Stéfan van der Walt wrote: > >> On Tue, Jul 9, 2013 at 2:55 PM, Chao YUE <[email protected]> wrote: > >>> I am using 1.7.1 version of numpy and np.ma.argmax is not repecting the > >>> mask? > >>> > >>> In [96]: d3 > >>> Out[96]: > >>> masked_array(data = > >>> [[-- -- -- -- 4] > >>> [5 -- 7 8 9]], > >>> mask = > >>> [[ True True True True False] > >>> [False True False False False]], > >>> fill_value = 6) > >>> > >>> > >>> In [97]: np.ma.argmax(d3,axis=0) > >>> Out[97]: array([1, 0, 1, 1, 1]) > >> > >> This is the result I would expect. If both values are masked, the > >> fill value is used, so there is always an argmin value. > >> > > > > To be honest, I would expect the exact opposite. If there is no value, > > there is no minimum argument -> either its an error, or it signals > > invalid in some other way. On masked arrays I would expect it to be > > masked to signal this. > > The doc is quite clear: masked values are replaced by `fill_value` when > determining the argmax/argmin. Attaching a mask a posteriori is always > doable, but making the output of np.ma.argstuff a MaskedArray may be a > nuisance at this point (any input from heavy users?). > > _______________________________________________ > NumPy-Discussion mailing list > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion > -- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
