Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spec/draft/API_specification/manipulation_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ Objects in API
roll
squeeze
stack
tile
unstack
25 changes: 25 additions & 0 deletions src/array_api_stubs/_draft/manipulation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"roll",
"squeeze",
"stack",
"tile",
"unstack",
]

Expand Down Expand Up @@ -257,6 +258,30 @@ def stack(arrays: Union[Tuple[array, ...], List[array]], /, *, axis: int = 0) ->
"""


def tile(x: array, repetitions: Tuple[int, ...], /):
"""
Constructs an array by tiling a provided array.

Parameters
----------
x: array
input array.
repetitions: Tuple[int, ...]
number of repetitions along each axis (dimension).

Let ``N = len(x.shape)`` and ``M = len(repetitions)``.

If ``N > M``, the function must prepend ones until all axes (dimensions) are specified (e.g., if ``x`` has shape ``(8,6,4,2)`` and ``repetitions`` is the tuple ``(3,3)``, then ``repetitions`` must be treated as ``(1,1,3,3)``).

If ``N < M``, the function must prepend singleton axes (dimensions) to ``x`` until ``x`` has as many axes (dimensions) as ``repetitions`` specifies (e.g., if ``x`` has shape ``(4,2)`` and ``repetitions`` is the tuple ``(3,3,3,3)``, then ``x`` must be treated as if it has shape ``(1,1,4,2)``).

Returns
-------
out: array
a tiled output array. The returned array must have the same data type and the same rank (i.e., number of dimensions) as ``x``. If ``S`` is the shape of the tiled array after prepending singleton dimensions (if necessary) and ``r`` is the tuple of repetitions after prepending ones (if necessary), then the number of elements along each axis (dimension) must satisfy ``S[i]*r[i]``, where ``i`` refers to the ``i`` th axis (dimension).
"""


def unstack(x: array, /, *, axis: int = 0) -> Tuple[array, ...]:
"""
Splits an array in a sequence of arrays along the given axis.
Expand Down