I am using version 1.6.2 In [77]: np.__version__ Out[77]: '1.6.2'
On Thu, Nov 22, 2012 at 10:08 PM, Chao YUE <[email protected]> wrote: > Dear all, > > I tried the np.apply_over_axes and np.ma.apply_over_axes, it seems that > they are not working for the masked array? > I searched the wiki and there are two tickets (1480,8417) related with > this, it seems that it's a solved issue? > > the example is below: > > In [67]: a = np.arange(60.).reshape(3,4,5) > > In [68]: tempm = np.tile(np.array([True,True,False,False,False]),(3,4,1)) > > In [69]: b = np.ma.masked_array(a,mask=tempm) > > In [70]: np.apply_over_axes(np.ma.sum,a,[1,2]) > Out[70]: > array([[[ 190.]], > > [[ 590.]], > > [[ 990.]]]) > > In [71]: np.ma.sum(np.ma.sum(a,axis=1),axis=1) > Out[71]: array([ 190., 590., 990.]) > > In [72]: np.ma.sum(np.ma.sum(b,axis=1),axis=1) > Out[72]: > masked_array(data = [126.0 366.0 606.0], > mask = [False False False], > fill_value = 1e+20) > > > In [73]: np.apply_over_axes(np.ma.sum,b,[1,2]) > Out[73]: > array([[[ 190.]], > > [[ 590.]], > > [[ 990.]]]) > > In [74]: np.apply_over_axes(np.sum,b,[1,2]) > Out[74]: > array([[[ 190.]], > > [[ 590.]], > > [[ 990.]]]) > > In [75]: np.ma.apply_over_axes(np.sum,b,[1,2]) > Out[75]: > array([[[ 190.]], > > [[ 590.]], > > [[ 990.]]]) > > In [76]: np.ma.apply_over_axes(np.ma.sum,b,[1,2]) > Out[76]: > array([[[ 190.]], > > [[ 590.]], > > [[ 990.]]]) > > > thanks, > > Chao > > -- > > *********************************************************************************** > 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 > > ************************************************************************************ > > -- *********************************************************************************** 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
