[SciPy-user] possible to get INF in divide by zero ?

Stef Mientki s.mientki@ru...
Thu Aug 28 02:48:39 CDT 2008

Vincent Favre-Nicolin wrote:
> On jeudi 28 août 2008, Stef Mientki wrote:
>> I wonder if it's possible to get the MatLab behavior :
>> divide by zero gives infinite (INF) ?
>> I even wonder if something like INF exists in python / scipy / numpy.
>   Isn't this already the behaviour of numpy ?
> In [6]: ones(10)/0
> Warning: divide by zero encountered in divide
> Out[6]: array([ Inf,  Inf,  Inf,  Inf,  Inf,  Inf,  Inf,  Inf,  Inf,  Inf])
> 	Vincent
Thanks, so it works for arrays,
but not for normal integers:
 >>> 3/0
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero


Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629.
The Radboud University Nijmegen Medical Centre is listed in the Commercial Register of the Chamber of Commerce under file number 41055629.

More information about the SciPy-user mailing list