[Numpy-discussion] possible enhancement to getitem?
Jonathan T. Niehof
jniehof@lanl....
Fri Jun 8 08:51:53 CDT 2012
On 06/07/2012 12:55 PM, Neal Becker wrote:
> In [3]: u = np.arange(10)
>
> In [4]: u
> Out[4]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>
> In [5]: u[-2:]
> Out[5]: array([8, 9])
>
> In [6]: u[-2:2]
> Out[6]: array([], dtype=int64)
>
> I would argue for consistency it would be desirable for this to return
>
> [8, 9, 0, 1]
Should u[8:2] also return [8, 9, 0, 1], for consistency? That would be
the concatenation of u[8:] and u[:2], which seems to be your argument.
I concur with Alan that a numpy array should, to the extent possible,
remain a sequence type. It's a pretty good duck without a peacock tail ;)
--
Jonathan Niehof
ISR-3 Space Data Systems
Los Alamos National Laboratory
MS-D466
Los Alamos, NM 87545
Phone: 505-667-9595
email: jniehof@lanl.gov
Correspondence /
Technical data or Software Publicly Available
More information about the NumPy-Discussion
mailing list