flatten

Contents

flatten#

class brainunit.math.flatten(x, start_axis=None, end_axis=None, **kwargs)#

Flattens input by reshaping it into a one-dimensional tensor. If start_dim or end_dim are passed, only dimensions starting with start_dim and ending with end_dim are flattened. The order of elements in input is unchanged.

Note

Flattening a zero-dimensional tensor will return a one-dimensional view.

Parameters:
  • x (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity) – The input array.

  • start_axis (int | None) – the first dim to flatten

  • end_axis (int | None) – the last dim to flatten

Returns:

out

Return type:

Array | saiunit.Quantity

Examples

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