[NumPy-Tickets] [NumPy] #1864: arange using float for step and integer dtype results in an array with all values being the same

NumPy Trac numpy-tickets@scipy....
Fri Jun 10 10:35:46 CDT 2011


#1864: arange using float for step and integer dtype results in an array with all
values being the same
------------------------+---------------------------------------------------
 Reporter:  bsouthey    |       Owner:  somebody   
     Type:  defect      |      Status:  new        
 Priority:  normal      |   Milestone:  Unscheduled
Component:  numpy.core  |     Version:  devel      
 Keywords:              |  
------------------------+---------------------------------------------------
 When using a float step but a integer dtype, np.arange appears to full the
 array with a constant value (first value in the range) rather than an
 integer array of different integers or giving an error. The following code
 illustrates the problem:
 {{{
 >>> import numpy as np
 >>> np.__version__
 '2.0.0.dev-a1e7be3'
 >>> np.arange(0.,5.,0.5)
 array([ 0. ,  0.5,  1. ,  1.5,  2. ,  2.5,  3. ,  3.5,  4. ,  4.5])
 >>> np.arange(0.,5.,0.5, dtype=int)
 array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
 >>> np.asarray(np.arange(0.,5.,0.5), dtype=int)
 array([0, 0, 1, 1, 2, 2, 3, 3, 4, 4])
 }}}

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1864>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list