X_train[y_train == y, :, :]
all_obs[train_index, ...]
What do this two lines of code means? what does comma means here? and what does "..." means here?
X_train[y_train == y, :, :]
all_obs[train_index, ...]
What do this two lines of code means? what does comma means here? and what does "..." means here?
If you define a class that implements __getitem__
you can examine the details:
class Foo(object):
def __getitem__(self, *xs, **kws):
return [xs, kws]
X_train = Foo()
all_obs = Foo()
y_train = 123
y = 123
train_index = 456
print X_train[y_train == y, :, :]
print all_obs[train_index, ...]
Output:
[((True, slice(None, None, None), slice(None, None, None)),), {}]
[((456, Ellipsis),), {}]
Looks like the colon defines an empty slice object, and the ellipsis is discussed in the links provided in comments above (What does the Python Ellipsis object do?).