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

Christopher Barker Chris.Barker at noaa.gov
Fri Mar 9 14:46:45 EST 2007


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

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

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

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

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list