pydims.expand_dims#

pydims.expand_dims(array, /, sizes)[source]#

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.

Parameters:
  • array (TypeVar(DimArr, bound= DimensionedArray)) – Array to expand.

  • sizes (dict[Hashable, int]) – Ordered names and sizes of the new dimensions.

Returns:

TypeVar(DimArr, bound= DimensionedArray) – Expanded array.