RectGrid.__getitem__

RectGrid.__getitem__(self, indices)[source]

Return self[indices].

Parameters
indicesindex expression

Object determining which parts of the grid to extract. None (new axis) and empty axes are not supported.

Examples

Indexing with integers along all axes produces an array (a point):

>>> g = RectGrid([-1, 0, 3], [2, 4, 5], [5], [2, 4, 7])
>>> g[0, 0, 0, 0]
array([-1.,  2.,  5.,  2.])

Otherwise, a new RectGrid is returned:

>>> g[:, 0, 0, 0]
RectGrid(
    [-1.,  0.,  3.],
    [ 2.],
    [ 5.],
    [ 2.]
)
>>> g[0, ..., 1:]
RectGrid(
    [-1.],
    [ 2.,  4.,  5.],
    [ 5.],
    [ 4.,  7.]
)
>>> g[::2, ..., ::2]
RectGrid(
    [-1.,  3.],
    [ 2.,  4.,  5.],
    [ 5.],
    [ 2.,  7.]
)

Too few indices are filled up with an ellipsis from the right:

>>> g[0]
RectGrid(
    [-1.],
    [ 2.,  4.,  5.],
    [ 5.],
    [ 2.,  4.,  7.]
)
>>> g[0] == g[0, :, :, :] == g[0, ...]
True