Skip to content

Commit 89d4ac0

Browse files
committed
Add values testing to test_repeat
1 parent c0c6ba9 commit 89d4ac0

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Diff for: array_api_tests/test_manipulation_functions.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,28 @@ def test_repeat(x, kw, data):
325325
expected_shape[axis] = n_repititions
326326
expected_shape = tuple(expected_shape)
327327
ph.assert_shape("repeat", out_shape=out.shape, expected=expected_shape)
328-
# TODO: values testing
329328

329+
# Test values
330+
331+
if isinstance(repeats, int):
332+
repeats_array = xp.full(size, repeats, dtype=xp.int32)
333+
else:
334+
repeats_array = repeats
335+
336+
if kw.get("axis") is None:
337+
x = xp.reshape(x, (-1,))
338+
axis = 0
339+
340+
for idx, in sh.iter_indices(x.shape, skip_axes=axis):
341+
x_slice = x[idx]
342+
out_slice = out[idx]
343+
start = 0
344+
for i, count in enumerate(repeats_array):
345+
end = start + count
346+
ph.assert_array_elements("repeat", out=out_slice[start:end],
347+
expected=xp.full((count,), x_slice[i], dtype=x.dtype),
348+
kw=kw)
349+
start = end
330350

331351
@st.composite
332352
def reshape_shapes(draw, shape):

0 commit comments

Comments
 (0)