[Numpy-discussion] 0/0 is 0 or nan?

Christopher Barker Chris.Barker@noaa....
Fri Mar 9 13:46:45 CST 2007

Robert Kern wrote:
> What version of numpy are you using?
 >>> from numpy import *
 >>> print __version__
 >>> a = array(0, dtype=int)
 >>> b = array(0, dtype=int)
 >>> divide(a, b)
Warning: divide by zero encountered in divide
 >>> geterr()
{'over': 'print', 'divide': 'print', 'invalid': 'print', 'under': 'ignore'}
 >>> divide(0.0, 0.0)
Warning: invalid value encountered in divide

I had reset error reporting to match the OP before. It looks like I get 
the same as you with the defaults.

There is no NaN for integers, so I guess 0 is as good as anything


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception


More information about the Numpy-discussion mailing list