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

Jaime Fernández del Río jaime.frio at gmail.com
Thu Oct 2 19:48:47 EDT 2014


On Thu, Oct 2, 2014 at 4:29 PM, Charles R Harris <charlesr.harris at gmail.com>
wrote:

>
>
> On Thu, Oct 2, 2014 at 5: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?
>>
>>
> In master on Fedora I get
>
> In [1]: np.array(0) / np.array(0)
> /home/charris/.local/bin/ipython:1: RuntimeWarning: divide by zero
> encountered in divide
>   #!/usr/bin/python
> Out[1]: 0
>

Exact same thing on Windows with master:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141002/0928f17d/attachment.html>


More information about the NumPy-Discussion mailing list