[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....
Wed Jun 15 13:40:28 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: |
------------------------+---------------------------------------------------
Comment(by bsouthey):
Replying to [comment:1 derek]:
> Actually it seems to construct something like np.arange(int(start),
int(stop), int(step)), although the length remains the same as for the
float array - compare
> {{{
> >>>np.arange(0,5,1.5, dtype=int)
> array([0, 1, 2, 3])
> }}}
Actually that is not the expected output either because it is dropping the
last element(s) as seen when ignoring the 'dtype' (with numpy 1.6.1rc1):
{{{
>>> np.arange(0,5,1.5)
array([ 0. , 1.5, 3. , 4.5])
>>> np.arange(0,5,1.5).astype(int)
array([0, 1, 3, 4])
>>> np.arange(0,20,1.5, dtype=int)
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
}}}
Initially I thought that np.arange(start, stop, step, dtype=int) should be
the same as np.arange(start, stop, step).astype(int). But really it should
infer the correct output dtype from all of the inputs and let the user
recast the dtype as needed.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1864#comment:2>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list