[Numpy-discussion] invalid numeric result(s) in divide

Warren Focke focke at slac.stanford.edu
Fri Aug 13 08:40:07 EDT 2004


On Fri, 13 Aug 2004, Curzio Basso wrote:

>  >>> tmp = NA.where(w > 0.0, tmp / w, 0.0)
> Warning: Encountered invalid numeric result(s)  in divide
>
> Ah, both matrices have no 'nan' or 'inf' elements. So, where could the
> invalid result come from?

All of the arguments to NA.where are evaluated before the function is
called, so tmp/w results in divide-by-zero.  The array that gets passed to
NA.where contains some inf or nan (I suspect the latter based on the
warning message), but you don't see them in the return value because
NA.where replaces them w/ 0.

Warren Focke





More information about the NumPy-Discussion mailing list