|
2 | 2 |
|
3 | 3 | from ._array_object import Array
|
4 | 4 | from ._creation_functions import asarray
|
5 |
| -from ._data_type_functions import result_type |
6 |
| -from ._dtypes import _integer_dtypes |
| 5 | +from ._data_type_functions import astype, result_type |
| 6 | +from ._dtypes import _integer_dtypes, int64, uint64 |
7 | 7 | from ._flags import requires_api_version, get_array_api_strict_flags
|
8 | 8 |
|
9 | 9 | from typing import TYPE_CHECKING
|
@@ -94,7 +94,13 @@ def repeat(
|
94 | 94 | else:
|
95 | 95 | raise TypeError("repeats must be an int or array")
|
96 | 96 |
|
97 |
| - return Array._new(np.repeat(x._array, repeats, axis=axis)) |
| 97 | + if repeats.dtype == uint64: |
| 98 | + # NumPy does not allow uint64 because can't be cast down to x.dtype |
| 99 | + # with 'safe' casting. However, repeats values larger than 2**63 are |
| 100 | + # infeasable, and even if they are present by mistake, this will |
| 101 | + # lead to underflow and an error. |
| 102 | + repeats = astype(repeats, int64) |
| 103 | + return Array._new(np.repeat(x._array, repeats._array, axis=axis)) |
98 | 104 |
|
99 | 105 | # Note: the optional argument is called 'shape', not 'newshape'
|
100 | 106 | def reshape(x: Array,
|
|
0 commit comments