pydims.DimensionedArray#
- class pydims.DimensionedArray(*, dims, values, unit)[source]#
Array with named dimensions and optional unit.
Methods
__init__(*, dims, values, unit)astype(dtype[, copy])- rtype:
TypeVar(DimArr, bound= DimensionedArray)
expand_dims(sizes)Expand an array by adding new dimensions of the given sizes at the beginning.
flatten(*[, dims, dim])Flatten a set of dimensions into a single dimension.
fold(dim, *, sizes)Fold a dimension of an array into a new set of dimensions.
permute_dims(dims)Permute the dimensions of an array.
reshape(**kwargs)Not supported since it relies on a particular axis order.
squeeze([dim])Remove dimensions of size 1.
to(*[, dtype, unit, copy])Convert to a new dtype and/or unit.
Attributes
array_namespacedimdimsdtypendimshapesizesizesunitunits_namespacevalues- __setitem__(key, array)[source]#
Set a sub-array identified by key to the values of array.
The array to set will be automatically transposed and/or broadcast to match the dimensions of the sub-array, using the named dimensions.
- expand_dims(sizes)#
Expand an array by adding new dimensions of the given sizes at the beginning.
Note that in contrast to the underlying expand_dims function, this function does not add dimensions of size 1, since this library implements broadcasting differently.
Use
permute_dims()to control the order of the old and new dimensions.
- flatten(*, dims=None, dim=None)#
Flatten a set of dimensions into a single dimension.
- fold(dim, *, sizes)#
Fold a dimension of an array into a new set of dimensions.
- permute_dims(dims)#
Permute the dimensions of an array.
- reshape(**kwargs)#
Not supported since it relies on a particular axis order.
This function of the Python Array API is not supported by PyDims because it relies on a particular axis order. This library does not support this since it can lead to errors that are hard to debug.
- Raises:
NotImplementedError – Always.
- Return type:
- squeeze(dim=None)#
Remove dimensions of size 1.