[Numpy-discussion] 0/0 == 0?

Benjamin Root ben.root at ou.edu
Thu Oct 2 21:06:07 EDT 2014


Out[1] has an integer divided by an integer, and you can't represent nan as
an integer. Perhaps something weird was happening with type promotion
between versions?

Ben Root
On Oct 2, 2014 7:02 PM, "T J" <tjhnson at gmail.com> wrote:

> Hi, I'm using NumPy 1.8.2:
>
> In [1]: np.array(0) / np.array(0)
> Out[1]: 0
>
> In [2]: np.array(0) / np.array(0.0)
> Out[2]: nan
>
> In [3]: np.array(0.0) / np.array(0)
>                                                             Out[3]: nan
>
> In [4]: np.array(0.0) / np.array(0.0)
> Out[4]: nan
>
>
> In [5]: 0/0
> ---------------------------------------------------------------------------
> ZeroDivisionError                         Traceback (most recent call last)
> <ipython-input-6-6549dea6d1ae> in <module>()
> ----> 1 0/0
>
> ZeroDivisionError: integer division or modulo by zero
>
>
>
> Out[1] seems odd. I get the right value in 1.8.1.  Was this fixed for
> 1.9.0?
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141002/45106834/attachment.html>


More information about the NumPy-Discussion mailing list