[NumPy-Tickets] [NumPy] #1671: scalars don't raise overflow/underflow/divbyzero/invalid
NumPy Trac
numpy-tickets@scipy....
Thu Nov 11 13:17:10 CST 2010
#1671: scalars don't raise overflow/underflow/divbyzero/invalid
------------------------+---------------------------------------------------
Reporter: m-paradox | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 2.0.0
Component: numpy.core | Version: devel
Keywords: |
------------------------+---------------------------------------------------
All these cases should be raising, I believe:
{{{
>>> import numpy as np
>>> err = np.seterr(all='raise')
>>> np.float32(1e-38) / np.float32(1e30)
0.0
>>> np.float32(1e-38) / np.array(1e38,np.float32)
0.0
>>> np.array(1e-38,np.float32) / np.float32(1e30)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FloatingPointError: underflow encountered in divide
>>> np.float64(1e-300) / np.float64(1e300)
0.0
>>> np.float64(1e-300) / np.array(1e300, dtype=np.float64)
0.0
>>> np.array(1e-300, dtype=np.float64) / np.float64(1e300)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FloatingPointError: underflow encountered in divide
>>> np.float32(1) / np.float32(0)
inf
>>> np.array(1,dtype=np.float32) / np.float32(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FloatingPointError: divide by zero encountered in divide
>>> np.inf-np.inf
nan
>>> np.array(np.inf)-np.inf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FloatingPointError: invalid value encountered in subtract
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1671>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list