[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 14:03:50 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 derek):
Replying to [comment:2 bsouthey]:
> 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,20,1.5, dtype=int)
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
}}}
That's (I think) what I meant by "the length remains the same", or more
precisely, it still has the same shape as np.arange(0,20,1.5,
dtype=float).
>
> 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.
>
You mean it first should compute np.arange(int(start), int(stop),
int(step)), and leave it to the user to apply astype() afterwards if so
desired? Still I am not sure this would be more useful behaviour, e.g. in
your original example you'd get a ZeroDivisionError.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1864#comment:3>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list