stack

Contents

stack#

class brainunit.math.stack(arrays, axis=0, dtype=None, **kwargs)#

Join a sequence of quantities or arrays along a new axis.

Parameters:
  • arrays (Sequence[Array | ndarray | bool | number | bool | int | float | complex] | Sequence[saiunit.Quantity]) – The arrays must have the same shape.

  • axis (int) – The axis in the result array along which the input arrays are stacked.

  • dtype (str | type[Any] | dtype | SupportsDType | None) – If provided, the concatenation will be done using this dtype. Otherwise, the array with the highest precision will be used.

Returns:

res – The stacked array has one more dimension than the input arrays.

Return type:

Array | saiunit.Quantity

Examples

>>> import saiunit as u
>>> a = [1, 2, 3] * u.second
>>> b = [4, 5, 6] * u.second
>>> u.math.stack([a, b])