[NumPy-Tickets] [NumPy] #879: Finite integer scalar arguments to nan_to_num gives incorrect result

NumPy Trac numpy-tickets@scipy....
Wed Mar 23 18:21:04 CDT 2011


#879: Finite integer scalar arguments to nan_to_num gives incorrect result
------------------------+---------------------------------------------------
 Reporter:  bsouthey    |       Owner:  somebody   
     Type:  defect      |      Status:  new        
 Priority:  low         |   Milestone:  Unscheduled
Component:  numpy.core  |     Version:  devel      
 Keywords:              |  
------------------------+---------------------------------------------------
Changes (by mwiebe):

  * priority:  lowest => low
  * version:  none => devel
  * milestone:  1.5.1 => Unscheduled


Old description:

> If an finite integer number is passed to nan_to_num then an array is
> returned.  But if a float or nonfinite number (nan or inf) is passed,
> then a NumPy float64 is returned.
>
> {{{
> import numpy as np
> type(np.nan_to_num(np.inf)) # returns: <type 'numpy.float64'>
> type(np.nan_to_num(1.0))    # returns: <type 'numpy.float64'>
> >>> type(np.nan_to_num(1))  # returns: <type 'numpy.ndarray'>
> }}}

New description:

 If an finite integer number is passed to nan_to_num then an array is
 returned.  But if a float or nonfinite number (nan or inf) is passed, then
 a NumPy float64 is returned.

 {{{
 import numpy as np
 type(np.nan_to_num(np.inf)) # returns: <type 'numpy.float64'>
 type(np.nan_to_num(1.0))    # returns: <type 'numpy.float64'>
 type(np.nan_to_num(1))  # returns: <type 'numpy.ndarray'>
 }}}

--

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


More information about the NumPy-Tickets mailing list