<div dir="ltr">Thanks Julian. Mistakenly, I have (a[:1:] + a[:1,:])/2 type of construct somewhere in my code. It works fine, however I wasn't sure if this is something leading to a wrong calculation. Now your explanation makes it clearer. <br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Feb 28, 2014 at 6:48 PM, Julian Taylor <span dir="ltr"><<a href="mailto:jtaylor.debian@googlemail.com" target="_blank">jtaylor.debian@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 01.03.2014 00:32, Gökhan Sever wrote:<br>
><br>
> Hello,<br>
><br>
> Given this simple 2D array:<br>
><br>
> In [1]: np.arange(9).reshape((3,3))<br>
> Out[1]:<br>
> array([[0, 1, 2],<br>
>        [3, 4, 5],<br>
>        [6, 7, 8]])<br>
><br>
> In [2]: a = np.arange(9).reshape((3,3))<br>
><br>
> In [3]: a[:1:]<br>
> Out[3]: array([[0, 1, 2]])<br>
><br>
> In [4]: a[:1,:]<br>
> Out[4]: array([[0, 1, 2]])<br>
><br>
> Could you tell me why the last two indexing (note the comma!) results in<br>
> the same array? Thanks.<br>
><br>
<br>
<br>
</div></div>if you specify less indices than dimensions the latter dimensions are<br>
implicitly all selected.<br>
so these are identical for three dimensional arrays:<br>
d = np.ones((3,3,3))<br>
d[1]<br>
d[1,:]<br>
d[1,:,:]<br>
d[1,...] (... or Ellipsis selects all remaining dimensions)<br>
<br>
this only applies to latter dimensions in the shape, if you want to<br>
select all earlier dimensions they have to be explicitly selected:<br>
d[:,1] == d[:,1,:]<br>
d[..., 1] = d[:,:,1]<br>
<br>
<br>
as for :1: vs 1:, its standard python rules: start:stop:step, with all<br>
three having defaults of 0:len(sequence):1<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Gökhan
</div>