[Numpy-discussion] 0/0 is 0 or nan?
Robert Kern
robert.kern@gmail....
Fri Mar 9 12:03:33 CST 2007
Christopher Barker wrote:
> Robert Kern wrote:
>> However, I believe that divide() on two Python ints goes through a different
>> path than for numpy arrays and numpy scalars. Rather, they are recognized as
>> objects that implement .__div__(), and that is called instead.
>
> Then wouldn't this be different:
>
> >>> a = N.array(0, dtype=N.int)
> >>> b = N.array(0, dtype=N.int)
> >>> N.divide(a,b)
> 0
What version of numpy are you using?
In [13]: from numpy import *
In [14]: a = array(0, dtype=int)
In [15]: b = array(0, dtype=int)
In [16]: divide(a, b)
Warning: divide by zero encountered in divide
Out[16]: 0
In [17]: geterr()
Out[17]: {'divide': 'print', 'invalid': 'print', 'over': 'print', 'under': 'ignore'}
In [18]: import numpy
In [19]: numpy.__version__
Out[19]: '1.0.2.dev3569'
--
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