Use one of the two predefined instances index_exp or s_
rather than directly using IndexExpression.
For any index combination, including slicing and axis insertion,
a[indices] is the same as a[np.index_exp[indices]] for any
array a. However, np.index_exp[indices] can be used anywhere
in Python code and returns a tuple of slice objects that can be
used in the construction of complex index expressions.
Predefined instance without tuple conversion: s_ = IndexExpression(maketuple=False). The index_exp is another predefined instance that always returns a tuple: index_exp = IndexExpression(maketuple=True).
Notes
You can do all this with slice plus a few special objects,
but there’s a lot to remember and this version is simpler because
it uses the standard array indexing syntax.