...@gmail.com
To: numpy-discussion@scipy.org
Cc:
Date: Tue, 25 Feb 2014 23:04:26 + (UTC)
Subject: [Numpy-discussion] Help Understanding Indexing Behavior
At the risk of igniting a flame war...can someone please help me understand
the indexing behavior of NumPy? I will readily I admit I come
JB jonathan.j.b...@gmail.com wrote:
x = np.array([1,2,3,4,5,6,7,8,9,10])
If I want the first 5 elements, what do I do?
x[:5]
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
On Wed, Feb 26, 2014 at 5:32 AM, Slavin, Jonathan
jsla...@cfa.harvard.eduwrote:
This behavior is a property of python slicing. It takes some getting used
to, but has its advantages.
quite a few, actually!
They key with slicing is to think of the index as pointing to the space
between the
At the risk of igniting a flame war...can someone please help me understand
the indexing behavior of NumPy? I will readily I admit I come from a Matlab
background, but I appreciate the power of Python and am trying to learn more.
From a Matlab user's perspective, the behavior of indexing in
On 26.02.2014 00:04, JB wrote:
At the risk of igniting a flame war...can someone please help me understand
the indexing behavior of NumPy? I will readily I admit I come from a Matlab
background, but I appreciate the power of Python and am trying to learn more.
From a Matlab user's
Think of the python indices as the edges of the boxes, whereas the
matlab indices are the boxes themselves.
matlab: [1][2][3][4]
python: 0[ ]1[ ]2[ ]3[ ]4[ ]5
you need to do 0:5 in python or you won't contain all the boxes!
On 25 February 2014 23:04, JB jonathan.j.b...@gmail.com wrote:
At the
To elaborate on what Julian wrote: it is indeed simply a convention;
slices/ranges in python are from the start to one-past-the-end. The reason
for the emergence of this convention is that C code using iterators looks
most natural this way. This manifests in a simple for (i = 0; i 5; i++),
but
On 26/02/2014 00:04, JB wrote:
At the risk of igniting a flame war...can someone please help me understand
the indexing behavior of NumPy? I will readily I admit I come from a Matlab
background, but I appreciate the power of Python and am trying to learn more.
From a Matlab user's
On Tue, Feb 25, 2014 at 6:01 PM, Daniele Nicolodi dani...@grinta.netwrote:
On 26/02/2014 00:04, JB wrote:
At the risk of igniting a flame war...can someone please help me
understand
the indexing behavior of NumPy? I will readily I admit I come from a
Matlab
background, but I appreciate