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

2012-12-14 Thread Robert Kern
On Fri, Dec 14, 2012 at 1:57 PM, Chao YUE chaoyue...@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@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


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

2012-12-14 Thread Chao YUE
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.k...@gmail.com wrote:

 On Fri, Dec 14, 2012 at 1:57 PM, Chao YUE chaoyue...@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@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

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


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

2012-12-14 Thread Robert Kern
On Fri, Dec 14, 2012 at 2:40 PM, Chao YUE chaoyue...@gmail.com wrote:
 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.

Precisely.

--
Robert Kern
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion