What does it mean ... mean in numpy code?

And what is it called? I do not know how to look for him; I tried calling it an ellipsis with google. I do not mean in the interactive output when the dots are used to indicate that the full array is not displayed, but as in the code that I am viewing,

xTensor0[...] = xVTensor[..., 0]

From my experiments, it seems to work with the index in a similar way : but it stands for a few : ', making x[:,:,1] equivalent to x[...,1] .

+6
python numpy
source share
3 answers

Yes you are right. It fills as much as possible : The only difference occurs when you use multiple ellipses. In this case, the first ellipsis acts the same, but each remaining one is converted to one :

+7
source share

Although this function exists mainly to support numpy and other similar modules, it is the main feature of the language and can be used anywhere, for example:

 >>> class foo: ... def __getitem__(self, key): ... return key ... >>> aFoo = foo() >>> aFoo[..., 1] (Ellipsis, 1) >>> 

or even:

 >>> derp = {} >>> derp[..., 1] = "herp" >>> derp {(Ellipsis, 1): 'herp'} 
+3
source share

Documentation here: http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html

It is good that you describe.

0
source share

All Articles