Indexable#
- class named_arrays.Indexable#
Bases:
ABCA mixin for immutable composite objects whose fields are named arrays.
This class provides a
shapeand a named__getitem__by delegating tonamed_arrays.shape()andnamed_arrays.getitem(), both of which recurse into thedataclassesfields of the object. A subclass is therefore expected to be an (immutable)dataclassesinstance whose fields are named arrays, or nested structures thereof.The
ndim,size, andaxesproperties are derived fromshape, so a subclass usually needs to define only its fields.Warning
Do not combine this mixin with
named_arrays.AbstractArrayor any other object recognized bynamed_arrays.named_array_like(). For such objectsnamed_arrays.shape()andnamed_arrays.getitem()index the object directly, which would recurse back into the properties defined here and never terminate.Attributes
The names of the axes of this object,
tuple(self.shape).The number of dimensions of this object,
len(self.shape).The broadcasted shape of every array-like field of this object.
The total number of elements in this object, the product of the values of
shape.Methods
__init__()isel(**item)Index every array-like field of this object along named axes given as keyword arguments.
Inheritance Diagram

- isel(**item)#
Index every array-like field of this object along named axes given as keyword arguments.
This is a convenience wrapper around
__getitem__():a.isel(x=0)is equivalent toa[dict(x=0)].Since keyword-argument names must be valid Python identifiers, axes whose names are not valid identifiers can only be indexed using the
dictform,a[{...}].- Parameters:
item (int | slice | AbstractArray) – The index to apply along each named axis.
self (Self)
- Return type: