[Numpy-discussion] Warning: invalid value encountered in true_divide?

Robert Kern robert.kern@gmail....
Wed Mar 30 12:19:24 CDT 2011


On Wed, Mar 30, 2011 at 12:12, Joon Ro <joonpyro@gmail.com> wrote:
> Hi,
> After numpy upgrade, I started to get "Warning: invalid value encountered in
> true_divide," when I run a code which did now show any warning previously.
> What does it mean and where should I look to fix this?

It means that a NaN popped up in a division somewhere. It always was
there, but some previous versions of numpy had the warnings
unintentionally silenced.

> It does not stop my
> debugger so I could not identify where the message was from.

You can use np.seterr() to change how these warnings are printed. In
particular, you can cause an exception to be raised so that you can
use a debugger to locate the source.

  http://docs.scipy.org/doc/numpy/reference/generated/numpy.seterr.html

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the NumPy-Discussion mailing list