On Mo, 2015-01-05 at 14:13 +0530, Maniteja Nandana wrote:
> Hi Anthony,
> 
> 
> I am not sure whether the following section in documentation is
> relevant to the behavior you were referring to.
> 
> 
> When an ellipsis (...) is present but has no size (i.e. replaces
> zero :) the result will still always be an array. A view if no
> advanced index is present, otherwise a copy.
> 

Exactly. There are actually three forms of indexing to distinguish.

1. Indexing with integers (also scalar arrays) matching the number of
dimensions. This will return a *scalar*.
2. Slicing, etc. which returns a view. This also occurs as soon there is
an ellipsis in there (even if it replaces 0 `:`). You should see it as a
feature to get a view if the result might be a scalar otherwise ;)!
3. Advanced indexing which cannot be view based and returns a copy.

- Sebastian


> Here, ...replaces zero :
> 
> 
> 
> Advanced indexing always returns a copy of the data (contrast with
> basic slicing that returns a view).
> And I think it is a view that is returned in this case.
> 
> 
> >>> a = array([1])
> >>>a
> array([1])
> >>>a[:,0]  # zero  : are present
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> IndexError: too many indices for array
> >>>a[...,0]=2
> >>>a
> array([2])
> >>>a[0] = 3
> >>>a
> array([3])
> >>>a[(0,)] = 4
> >>>a
> array([4])
> >>>a[:
> array([1])
> 
> 
> Hope I helped.
> 
> 
> Cheers,
> N.Maniteja.
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 
> 
> 
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to