[NumPy-Tickets] [NumPy] #2161: np.log gives RuntimeWarning for arrays with nan values when array is float32 but not float64

NumPy Trac numpy-tickets@scipy....
Fri Jun 15 11:14:05 CDT 2012


#2161: np.log gives RuntimeWarning for arrays with nan values when array is
float32 but not float64
------------------------+---------------------------------------------------
 Reporter:  cmorton     |       Owner:  somebody   
     Type:  defect      |      Status:  new        
 Priority:  low         |   Milestone:  Unscheduled
Component:  numpy.core  |     Version:  1.6.1      
 Keywords:              |  
------------------------+---------------------------------------------------

Comment(by cmorton):

 This seems like it might be related to Ticket #1360 and it is not just nan
 values

 {{{
 >>> np.log(np.array([0.0]).astype(np.float64))
 array([-inf])
 >>> np.log(np.array([0.0]).astype(np.float32))
 Traceback (most recent call last):
   File "<pyshell#82>", line 1, in <module>
     np.log(np.array([0.0]).astype(np.float32))
 FloatingPointError: divide by zero encountered in log

 >>> np.log(np.array([-1.0]).astype(np.float64))
 array([ nan])
 >>> np.log(np.array([-1.0]).astype(np.float32))
 Traceback (most recent call last):
   File "<pyshell#83>", line 1, in <module>
     np.log(np.array([-1.0]).astype(np.float32))
 FloatingPointError: invalid value encountered in log
 }}}

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/2161#comment:2>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list