ProductSpace.__getitem__

ProductSpace.__getitem__(self, indices)[source]

Return self[indices].

Examples

Integers are used to pick components, slices to pick ranges:

>>> r2, r3, r4 = odl.rn(2), odl.rn(3), odl.rn(4)
>>> pspace = odl.ProductSpace(r2, r3, r4)
>>> pspace[1]
rn(3)
>>> pspace[1:]
ProductSpace(rn(3), rn(4))

With lists, arbitrary components can be stacked together:

>>> pspace[[0, 2, 1, 2]]
ProductSpace(rn(2), rn(4), rn(3), rn(4))

Tuples, i.e. multi-indices, will recursively index higher-order product spaces. However, remaining indices cannot be passed down to component spaces that are not product spaces:

>>> pspace2 = odl.ProductSpace(pspace, 3)  # 2nd order product space
>>> pspace2
ProductSpace(ProductSpace(rn(2), rn(3), rn(4)), 3)
>>> pspace2[0]
ProductSpace(rn(2), rn(3), rn(4))
>>> pspace2[1, 0]
rn(2)
>>> pspace2[:-1, 0]
ProductSpace(rn(2), 2)