[Python-Dev] RE: [Numpy-discussion] RE: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison)

Janko Hauser jhauser at ifm.uni-kiel.de
Thu Oct 12 02:37:08 CDT 2000


To look for another way out of this, the current problem are the two
different wishes for vectorized computations to have NaN/Inf or
Exceptions. As the actual computations for NumPy are all done in C,
isn't it possible to implement a special signal handling in the NumPy
code? As an option, for the people who know that they are then
possibly in trouble (different behavior for arrays than for Python
scalars)


__Janko

Just for the record.

Python 1.5.2 (#1, May 10 1999, 18:46:39)  [GCC egcs-2.91.60 Debian 2.1 (egcs-1.1. on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
(IPP)
Type ? for more help

>>> import math
>>> math.sqrt(-1)
Traceback (innermost last):
  File "<console>", line 1, in ?
OverflowError: math range error
>>> math.exp(-800)
0.0
>>> math.exp(800)
inf
>>> 
>>> import Numeric
>>> Numeric.exp(Numeric.array([800, -800.]))
array([              inf,   0.00000000e+000])
>>> Numeric.sqrt(Numeric.array([-1]))
array([              nan])
>>> # So the current behavior is already inconsistent on at least one
>>> # platform

# Other platform (DEC Alpha) raising domain error 

Python 1.5.2 (#6, Sep 20 1999, 17:44:09) [C] on osf1V4
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import math
>>> math.exp(-800)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
OverflowError: math range error
>>> math.exp(800)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
OverflowError: math range error
>>> math.sqrt(-1)
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ValueError: math domain error
>>> import Numeric
>>> Numeric.exp(Numeric.array([800, -800.]))
Traceback (innermost last):
  File "<stdin>", line 1, in ?
OverflowError: math range error
>>> Numeric.sqrt(Numeric.array([-1]))
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ValueError: math domain error




More information about the Numpy-discussion mailing list