arkouda.array_api.manipulation_functions

Functions

broadcast_arrays(...)

Broadcast arrays to a common shape.

broadcast_to(→ arkouda.array_api.array_object.Array)

Broadcast the array to the specified shape.

concat(→ arkouda.array_api.array_object.Array)

Concatenate arrays along an axis.

expand_dims(→ arkouda.array_api.array_object.Array)

Create a new array with an additional dimension inserted at the specified axis.

flip(→ arkouda.array_api.array_object.Array)

Reverse an array's values along a particular axis or axes.

moveaxis(→ arkouda.array_api.array_object.Array)

Move axes of an array to new positions.

permute_dims(→ arkouda.array_api.array_object.Array)

Permute the dimensions of an array.

repeat(→ arkouda.array_api.array_object.Array)

Repeat elements of an array.

reshape(→ arkouda.array_api.array_object.Array)

Reshape an array to a new shape.

roll(→ arkouda.array_api.array_object.Array)

Roll the values in an array by the specified shift(s) along the specified axis or axes.

squeeze(→ arkouda.array_api.array_object.Array)

Remove degenerate (size one) dimensions from an array.

stack(→ arkouda.array_api.array_object.Array)

Stack arrays along a new axis.

tile(→ arkouda.array_api.array_object.Array)

Tile an array with the specified number of repetitions along each dimension.

unstack(→ Tuple[arkouda.array_api.array_object.Array, ...)

Decompose an array along an axis into multiple arrays of the same shape.

Module Contents

arkouda.array_api.manipulation_functions.broadcast_arrays(*arrays: arkouda.array_api.array_object.Array) List[arkouda.array_api.array_object.Array][source]

Broadcast arrays to a common shape.

Throws a ValueError if a common shape cannot be determined.

arkouda.array_api.manipulation_functions.broadcast_to(x: arkouda.array_api.array_object.Array, /, shape: Tuple[int, Ellipsis]) arkouda.array_api.array_object.Array[source]

Broadcast the array to the specified shape.

See: https://data-apis.org/array-api/latest/API_specification/broadcasting.html for details.

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

Concatenate arrays along an axis.

Parameters:
  • arrays (Tuple[Array, ...] or List[Array]) – The arrays to concatenate. Must have the same shape except along the concatenation axis.

  • axis (int, optional) – The axis along which to concatenate the arrays. The default is 0. If None, the arrays are flattened before concatenation.

arkouda.array_api.manipulation_functions.expand_dims(x: arkouda.array_api.array_object.Array, /, *, axis: int) arkouda.array_api.array_object.Array[source]

Create a new array with an additional dimension inserted at the specified axis.

Parameters:
  • x (Array) – The array to expand

  • axis (int) – The axis at which to insert the new (size one) dimension. Must be in the range [-x.ndim-1, x.ndim].

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

Reverse an array’s values along a particular axis or axes.

Parameters:
  • x (Array) – The array to flip

  • axis (int or Tuple[int, ...], optional) – The axis or axes along which to flip the array. If None, flip the array along all axes.

arkouda.array_api.manipulation_functions.moveaxis(x: arkouda.array_api.array_object.Array, source: int | Tuple[int, Ellipsis], destination: int | Tuple[int, Ellipsis], /) arkouda.array_api.array_object.Array[source]

Move axes of an array to new positions.

Parameters:
  • x (Array) – The array whose axes are to be reordered

  • source (int or Tuple[int, ...]) – Original positions of the axes to move. Values must be unique and fall within the range [-x.ndim, x.ndim).

  • destination (int or Tuple[int, ...]) – Destination positions for each of the original axes. Must be the same length as source. Values must be unique and fall within the range [-x.ndim, x.ndim).

arkouda.array_api.manipulation_functions.permute_dims(x: arkouda.array_api.array_object.Array, /, axes: Tuple[int, Ellipsis]) arkouda.array_api.array_object.Array[source]

Permute the dimensions of an array.

Parameters:
  • x (Array) – The array whose dimensions are to be permuted

  • axes (Tuple[int, ...]) – The new order of the dimensions. Must be a permutation of the integers from 0 to x.ndim-1.

arkouda.array_api.manipulation_functions.repeat(x: arkouda.array_api.array_object.Array, repeats: int | arkouda.array_api.array_object.Array, /, *, axis: int | None = None) arkouda.array_api.array_object.Array[source]

Repeat elements of an array.

Parameters:
  • x (Array) – The array whose values to repeat

  • repeats (int or Array) –

    The number of repetitions for each element.
    • If axis is None, must be an integer, or a 1D array of integers with the same size as x.

    • If axis is not None, must be an integer, or a 1D array of integers whose size matches the number of elements along the specified axis.

  • axis (int, optional) – The axis along which to repeat elements. If None, the array is flattened before repeating.

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

Reshape an array to a new shape.

Parameters:
  • x (Array) – The array to reshape

  • shape (Tuple[int, ...]) – The new shape for the array. Must have the same number of elements as the original array.

  • copy (bool, optional) – Whether to create a copy of the array. WARNING: currently always creates a copy, ignoring the value of this parameter.

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

Roll the values in an array by the specified shift(s) along the specified axis or axes. Elements that roll beyond the last position are re-introduced at the first position.

Parameters:
  • x (Array) – The array to roll

  • shift (int or Tuple[int, ...]) – The number of positions by which to shift each axis. If axis and shift are both tuples, they must have the same length and the i-th element of shift is the number of positions to shift axis[i]. If axis is a tuple and shift is an integer, the same shift is applied to each axis. If axis is None, must be an integer or a one-tuple.

  • axis (int or Tuple[int, ...], optional) – The axis or axes along which to roll the array. If None, the array is flattened before rolling.

arkouda.array_api.manipulation_functions.squeeze(x: arkouda.array_api.array_object.Array, /, axis: int | Tuple[int, Ellipsis]) arkouda.array_api.array_object.Array[source]

Remove degenerate (size one) dimensions from an array.

Parameters:
  • x (Array) – The array to squeeze

  • axis (int or Tuple[int, ...]) – The axis or axes to squeeze (must have a size of one).

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

Stack arrays along a new axis.

The resulting array will have one more dimension than the input arrays with a size equal to the number of input arrays.

Parameters:
  • arrays (Tuple[Array, ...] or List[Array]) – The arrays to stack. Must have the same shape.

  • axis (int, optional) – The axis along which to stack the arrays. Must be in the range [-N, N), where N is the number of dimensions in the input arrays. The default is 0.

arkouda.array_api.manipulation_functions.tile(x: arkouda.array_api.array_object.Array, repetitions: Tuple[int, Ellipsis], /) arkouda.array_api.array_object.Array[source]

Tile an array with the specified number of repetitions along each dimension.

Parameters:
  • x (Array) – The array to tile

  • repetitions (Tuple[int, ...]) – The number of repetitions along each dimension. If there are more repetitions than array dimensions, singleton dimensions are prepended to the array to make it match the number of repetitions. If there are more array dimensions than repetitions, ones are prepended to the repetitions tuple to make it’s length match the number of array dimensions.

arkouda.array_api.manipulation_functions.unstack(x: arkouda.array_api.array_object.Array, /, *, axis: int = 0) Tuple[arkouda.array_api.array_object.Array, Ellipsis][source]

Decompose an array along an axis into multiple arrays of the same shape.

Parameters:
  • x (Array) – The array to unstack

  • axis (int, optional) – The axis along which to unstack the array. The default is 0.