coordax.Field.unwrap

Field.unwrap(*names: str | Coordinate) ndarray | Array | NDArray[source]

Extracts underlying data from a field without named dimensions.

This is effectively syntactic sugar for assert field.named_dims == names, followed by returning field.data.

Parameters:

*names – Names of dimensions to check against.

Returns:

The underlying data array.

Raises:

ValueError – If the field has named dimensions that do not match names.

Examples

>>> import coordax as cx
>>> import jax.numpy as jnp
>>> field = cx.field(jnp.ones((2, 3)), 'x', 'y')
>>> field.unwrap('x', 'y')
Array([[1., 1., 1.], [1., 1., 1.]], dtype=float32)
>>> field.unwrap('y', 'x')
Traceback (most recent call last):
...
ValueError: Field has self.named_dims=('x', 'y') but names=('y', 'x') were
requested.