[Numpy-discussion] np.seterr doesn't work for masked array?

Chao YUE chaoyuejoy at gmail.com
Fri Dec 14 09:40:21 EST 2012


Thanks. You mean actually when numpy handle masked array, it will first
treat all the base data, and then apply the mask after the treatment.
and normally the base data of maksed elements will very likely to intrigure
these errors, and you will see a lot errory warning or print in the process,
and will make it impossible to see the error information your want to see
for those elements that are not masked but still can intriguer the error
you would like to see or check. I didn't realize this. It's a good to
overwrite the error setting.

thanks for your explanation.

Chao


On Fri, Dec 14, 2012 at 3:15 PM, Robert Kern <robert.kern at gmail.com> wrote:

> On Fri, Dec 14, 2012 at 1:57 PM, Chao YUE <chaoyuejoy at gmail.com> wrote:
> > Dear all,
> >
> > I tried to capture the zero divide error when I divide a masked array by
> > another. It seems that np.seterr is not working for masked array?
> > when I do np.divide on two masked array, it directly put the zero divides
> > part as being masked. The np.seterr works if the two arrays for dividing
> are
> > not masked arrays.
> > could anyone explain? thanks!!
>
> numpy.ma uses np.seterr(divide='ignore', invalid='ignore') for most of
> its operations, so it is overriding your settings. This is usually
> desirable since many of the masked values will be trip these errors
> spuriously even though they will be masked out in the result.
>
> --
> Robert Kern
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> 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
************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20121214/79077b0e/attachment.html>


More information about the NumPy-Discussion mailing list