__getitem__#
- RigidTransform.__getitem__(indexer)[source]#
Extract transform(s) at given index(es) from this object.
Creates a new
RigidTransform
instance containing a subset of transforms stored in this object.- Parameters:
- indexerint or slice or array_like
Specifies which transform(s) to extract. A single indexer must be specified, i.e. as if indexing a 1 dimensional array or list.
- Returns:
- transform
RigidTransform
instance - Contains
a single transform, if indexer is a single index
a stack of transform(s), if indexer is a slice, or an index array.
- transform
- Raises:
- TypeError
If the transform is a single transform.
Notes
Array API Standard Support
__getitem__
has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variableSCIPY_ARRAY_API=1
and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.Library
CPU
GPU
NumPy
✅
n/a
CuPy
n/a
✅
PyTorch
✅
✅
JAX
⚠️ no JIT
⚠️ no JIT
Dask
⛔
n/a
See Support for the array API standard for more information.
Examples
>>> from scipy.spatial.transform import RigidTransform as Tf >>> t = [[0, 0, 0], [1, 0, 0], [2, 0, 0]] # 3 translations >>> tf = Tf.from_translation(t)
A single index returns a single transform:
>>> tf[0].as_matrix() array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]])
A slice returns a stack of transforms:
>>> tf[1:3].translation array([[1., 0., 0.], [2., 0., 0.]])
An index array returns a stack of transforms:
>>> tf[[0, 2]].translation array([[0., 0., 0.], [2., 0., 0.]])