Skip to content

Commit dc1baad

Browse files
committed
Add tile()
1 parent f26bd49 commit dc1baad

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

array_api_strict/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,10 @@
284284
roll,
285285
squeeze,
286286
stack,
287+
tile,
287288
)
288289

289-
__all__ += ["concat", "expand_dims", "flip", "moveaxis", "permute_dims", "repeat", "reshape", "roll", "squeeze", "stack"]
290+
__all__ += ["concat", "expand_dims", "flip", "moveaxis", "permute_dims", "repeat", "reshape", "roll", "squeeze", "stack", "tile"]
290291

291292
from ._searching_functions import argmax, argmin, nonzero, searchsorted, where
292293

array_api_strict/_manipulation_functions.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,16 @@ def stack(arrays: Union[Tuple[Array, ...], List[Array]], /, *, axis: int = 0) ->
154154
result_type(*arrays)
155155
arrays = tuple(a._array for a in arrays)
156156
return Array._new(np.stack(arrays, axis=axis))
157+
158+
159+
@requires_api_version('2023.12')
160+
def tile(x: Array, repetitions: Tuple[int, ...], /) -> Array:
161+
"""
162+
Array API compatible wrapper for :py:func:`np.tile <numpy.tile>`.
163+
164+
See its docstring for more information.
165+
"""
166+
# Note: NumPy allows repetitions to be an int or array
167+
if not isinstance(repetitions, tuple):
168+
raise TypeError("repetitions must be a tuple")
169+
return Array._new(np.tile(x._array, repetitions))

0 commit comments

Comments
 (0)