heat.array_api._manipulation_functions

Module Contents

concat(arrays: Tuple[heat.array_api._array_object.Array, Ellipsis] | List[heat.array_api._array_object.Array], /, *, axis: int | None = 0) heat.array_api._array_object.Array[source]

Joins a sequence of arrays along an existing axis.

Parameters:
  • arrays (Union[Tuple[Array, ...], List[Array]]) – Input arrays to join. The arrays must have the same shape, except in the dimension specified by axis.

  • axis (Optional[int]) – Axis along which the arrays will be joined. If axis is None, arrays are flattened before concatenation. Default: 0.

expand_dims(x: heat.array_api._array_object.Array, /, *, axis: int = 0) heat.array_api._array_object.Array[source]

Expands the shape of an array by inserting a new axis (dimension) of size one at the position specified by axis.

Parameters:
  • x (Array) – Input array.

  • axis (int) – Axis position (zero-based). If x has rank (i.e, number of dimensions) N, a valid axis must reside on the closed-interval [-N-1, N].

flip(x: heat.array_api._array_object.Array, /, *, axis: int | Tuple[int, Ellipsis] | None = None) heat.array_api._array_object.Array[source]

Reverses the order of elements in an array along the given axis. The shape of the array is preserved.

Parameters:
  • x (Array) – Input array.

  • axis (Optional[Union[int, Tuple[int, ...]]]) – Axis (or axes) along which to flip. If axis is None, the function flips all input array axes.

permute_dims(x: heat.array_api._array_object.Array, /, axes: Tuple[int, Ellipsis]) heat.array_api._array_object.Array[source]

Permutes the axes (dimensions) of an array x.

Parameters:
  • x (Array) – Input array.

  • axes (Tuple[int, ...]) – Tuple containing a permutation of (0, 1, ..., N-1) where N is the number of axes (dimensions) of x.

reshape(x: heat.array_api._array_object.Array, /, shape: Tuple[int, Ellipsis], *, copy: bool | None = None) heat.array_api._array_object.Array[source]

Reshapes an array without changing its data.

Parameters:
  • x (Array) – Input array to reshape.

  • shape (Tuple[int, ...]) – A new shape compatible with the original shape. One shape dimension is allowed to be -1. When a shape dimension is -1, the corresponding output array shape dimension is inferred from the length of the array and the remaining dimensions.

  • copy (Optional[bool]) – Boolean indicating whether or not to copy the input array.

roll(x: heat.array_api._array_object.Array, /, shift: int | Tuple[int, Ellipsis], *, axis: int | Tuple[int, Ellipsis] | None = None) heat.array_api._array_object.Array[source]

Rolls array elements along a specified axis. Array elements that roll beyond the last position are re-introduced at the first position. Array elements that roll beyond the first position are re-introduced at the last position.

Parameters:
  • x (Array) – Input array.

  • shift (Union[int, Tuple[int, ...]]) – Number of places by which the elements are shifted. If shift is a tuple, then axis must be a tuple of the same size, and each of the given axes is shifted by the corresponding element in shift. If shift is an int and axis a tuple, then the same shift is used for all specified axes.

  • axis (Optional[Union[int, Tuple[int, ...]]]) – Axis (or axes) along which elements to shift. If axis is None, the array is flattened, shifted, and then restored to its original shape. Default: None.

squeeze(x: heat.array_api._array_object.Array, /, axis: int | Tuple[int, Ellipsis]) heat.array_api._array_object.Array[source]

Removes singleton dimensions (axes) from x.

Parameters:
  • x (Array) – Input array.

  • axis (Union[int, Tuple[int, ...]]) – Axis (or axes) to squeeze.

Raises:

ValueError`, if an axis is selected with shape entry greater than one

stack(arrays: Tuple[heat.array_api._array_object.Array, Ellipsis] | List[heat.array_api._array_object.Array], /, *, axis: int = 0) heat.array_api._array_object.Array[source]

Joins a sequence of arrays along a new axis.

Parameters:
  • arrays (Union[Tuple[array, ...], List[array]]) – Input arrays to join. Each array must have the same shape.

  • axis (int) – Axis along which the arrays will be joined.