I have a large array and a function that returns index lists into the array, i.e.,
import numpy n = 500 a = numpy.random.rand(n) def get_idx(k): # M
NumPy has a helper np.s_[] which can be used to construct slice and Ellipsis objects:
slice
Ellipsis
def get_idx(k): return np.s_[:] if k > 6 else np.s_[:k] # or even np.s_[:None if k > 6 else k]
In general, a[np.s_[ ]] is exactly the same as a[ ].
a[np.s_[ ]]
a[ ]