mpi_array.globale_ufunc.shape_extend_dims

mpi_array.globale_ufunc.shape_extend_dims(ndim, shape)[source]

Returns shape pre-prepended with ones so returned 1D array has length ndim.

Parameters:
  • ndim (int) – Length of returned 1D sequence.
  • shape (sequence of object) – Length of returned 1D sequence.
Return type:

tuple

Returns:

Sequence pre-pended with one elements so that sequence length equals ndim.

Example:

>>> shape_extend_dims(5, (3, 1, 5))
(1, 1, 3, 1, 5)
>>> shape_extend_dims(3, (3, 1, 5))
(3, 1, 5)
>>> shape_extend_dims(1, (3, 1, 5))
(3, 1, 5)