mardi 14 juin 2016

Explain how indexing and ellipsis works in numpy?


Can you please explain how does dots works in numpy? I am not able to understand the use of so many : in indexing, e.g. a[,:,:,]. Why do we need such type of indexing?

http://scipy.github.io/old-wiki/pages/Tentative_NumPy_Tutorial.html

Also, please explain me the use of dots.

The dots (...) represent as many colons as needed to produce a complete indexing tuple. For example, if x is a rank 5 array (i.e., it has 5 axes), then

x[1,2,...] is equivalent to x[1,2,:,:,:],

x[...,3] to x[:,:,:,:,3] and

x[4,...,5,:] to x[4,:,:,5,:]. 

What is this and why is it helpful to me?

Thanks!


Aucun commentaire:

Enregistrer un commentaire