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

Robert Kern robert.kern at gmail.com
Fri Dec 14 09:15:52 EST 2012


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



More information about the NumPy-Discussion mailing list