From cf3bf263923e09cdc949cdf0abbba8011c9cc3de Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Fri, 21 Nov 2025 15:21:59 +0100 Subject: [PATCH 1/5] ENH: add "repro_snippets" to test_utility_functions.py --- array_api_tests/test_utility_functions.py | 122 +++++++++++++--------- 1 file changed, 72 insertions(+), 50 deletions(-) diff --git a/array_api_tests/test_utility_functions.py b/array_api_tests/test_utility_functions.py index b6e0a4fe..9d136dcb 100644 --- a/array_api_tests/test_utility_functions.py +++ b/array_api_tests/test_utility_functions.py @@ -18,23 +18,28 @@ def test_all(x, data): kw = data.draw(hh.kwargs(axis=hh.axes(x.ndim), keepdims=st.booleans()), label="kw") keepdims = kw.get("keepdims", False) - out = xp.all(x, **kw) - - ph.assert_dtype("all", in_dtype=x.dtype, out_dtype=out.dtype, expected=xp.bool) - _axes = sh.normalize_axis(kw.get("axis", None), x.ndim) - ph.assert_keepdimable_shape( - "all", in_shape=x.shape, out_shape=out.shape, axes=_axes, keepdims=keepdims, kw=kw - ) - scalar_type = dh.get_scalar_type(x.dtype) - for indices, out_idx in zip(sh.axes_ndindex(x.shape, _axes), sh.ndindex(out.shape)): - result = bool(out[out_idx]) - elements = [] - for idx in indices: - s = scalar_type(x[idx]) - elements.append(s) - expected = all(elements) - ph.assert_scalar_equals("all", type_=scalar_type, idx=out_idx, - out=result, expected=expected, kw=kw) + repro_snippet = ph.format_snippet(f"xp.all({x!r}, **kw) with {kw = }") + try: + out = xp.all(x, **kw) + + ph.assert_dtype("all", in_dtype=x.dtype, out_dtype=out.dtype, expected=xp.bool) + _axes = sh.normalize_axis(kw.get("axis", None), x.ndim) + ph.assert_keepdimable_shape( + "all", in_shape=x.shape, out_shape=out.shape, axes=_axes, keepdims=keepdims, kw=kw + ) + scalar_type = dh.get_scalar_type(x.dtype) + for indices, out_idx in zip(sh.axes_ndindex(x.shape, _axes), sh.ndindex(out.shape)): + result = bool(out[out_idx]) + elements = [] + for idx in indices: + s = scalar_type(x[idx]) + elements.append(s) + expected = all(elements) + ph.assert_scalar_equals("all", type_=scalar_type, idx=out_idx, + out=result, expected=expected, kw=kw) + except Exception as exc: + exc.add_note(repro_snippet) + raise @pytest.mark.unvectorized @@ -46,23 +51,28 @@ def test_any(x, data): kw = data.draw(hh.kwargs(axis=hh.axes(x.ndim), keepdims=st.booleans()), label="kw") keepdims = kw.get("keepdims", False) - out = xp.any(x, **kw) - - ph.assert_dtype("any", in_dtype=x.dtype, out_dtype=out.dtype, expected=xp.bool) - _axes = sh.normalize_axis(kw.get("axis", None), x.ndim) - ph.assert_keepdimable_shape( - "any", in_shape=x.shape, out_shape=out.shape, axes=_axes, keepdims=keepdims, kw=kw, - ) - scalar_type = dh.get_scalar_type(x.dtype) - for indices, out_idx in zip(sh.axes_ndindex(x.shape, _axes), sh.ndindex(out.shape)): - result = bool(out[out_idx]) - elements = [] - for idx in indices: - s = scalar_type(x[idx]) - elements.append(s) - expected = any(elements) - ph.assert_scalar_equals("any", type_=scalar_type, idx=out_idx, - out=result, expected=expected, kw=kw) + repro_snippet = ph.format_snippet(f"xp.any({x!r}, **kw) with {kw = }") + try: + out = xp.any(x, **kw) + + ph.assert_dtype("any", in_dtype=x.dtype, out_dtype=out.dtype, expected=xp.bool) + _axes = sh.normalize_axis(kw.get("axis", None), x.ndim) + ph.assert_keepdimable_shape( + "any", in_shape=x.shape, out_shape=out.shape, axes=_axes, keepdims=keepdims, kw=kw, + ) + scalar_type = dh.get_scalar_type(x.dtype) + for indices, out_idx in zip(sh.axes_ndindex(x.shape, _axes), sh.ndindex(out.shape)): + result = bool(out[out_idx]) + elements = [] + for idx in indices: + s = scalar_type(x[idx]) + elements.append(s) + expected = any(elements) + ph.assert_scalar_equals("any", type_=scalar_type, idx=out_idx, + out=result, expected=expected, kw=kw) + except Exception as exc: + exc.add_note(repro_snippet) + raise @pytest.mark.unvectorized @@ -85,19 +95,24 @@ def test_diff(x, data): n = data.draw(st.integers(1, min(x.shape[n_axis], 3))) - out = xp.diff(x, **axis_kw, n=n) + repro_snippet = ph.format_snippet(f"xp.diff({x!r}, **axis_kw, n={n!r}) with {axis_kw = }") + try: + out = xp.diff(x, **axis_kw, n=n) - expected_shape = list(x.shape) - expected_shape[n_axis] -= n + expected_shape = list(x.shape) + expected_shape[n_axis] -= n - assert out.shape == tuple(expected_shape) + assert out.shape == tuple(expected_shape) - # value test - if n == 1: - for idx in sh.ndindex(out.shape): - l = list(idx) - l[n_axis] += 1 - assert out[idx] == x[tuple(l)] - x[idx], f"diff failed with {idx = }" + # value test + if n == 1: + for idx in sh.ndindex(out.shape): + l = list(idx) + l[n_axis] += 1 + assert out[idx] == x[tuple(l)] - x[idx], f"diff failed with {idx = }" + except Exception as exc: + exc.add_note(repro_snippet) + raise @pytest.mark.min_version("2024.12") @@ -130,12 +145,19 @@ def test_diff_append_prepend(x, data): prepend_shape[n_axis] = prepend_axis_len prepend = data.draw(hh.arrays(dtype=x.dtype, shape=tuple(prepend_shape)), label="prepend") - out = xp.diff(x, **axis_kw, n=n, append=append, prepend=prepend) + repro_snippet = ph.format_snippet( + f"xp.diff({x!r}, **axis_kw, n={n!r}, append={append!r}, prepend={prepend!r}) with {axis_kw = }" + ) + try: + out = xp.diff(x, **axis_kw, n=n, append=append, prepend=prepend) - in_1 = xp.concat((prepend, x, append), **axis_kw) - out_1 = xp.diff(in_1, **axis_kw, n=n) + in_1 = xp.concat((prepend, x, append), **axis_kw) + out_1 = xp.diff(in_1, **axis_kw, n=n) - assert out.shape == out_1.shape - for idx in sh.ndindex(out.shape): - assert out[idx] == out_1[idx], f"{idx = }" + assert out.shape == out_1.shape + for idx in sh.ndindex(out.shape): + assert out[idx] == out_1[idx], f"{idx = }" + except Exception as exc: + exc.add_note(repro_snippet) + raise From 50895883c162cc8678df299441640b3faa6418ba Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Fri, 21 Nov 2025 15:22:19 +0100 Subject: [PATCH 2/5] ENH: add "repro_snippets" to test_indexing_functions.py --- array_api_tests/test_indexing_functions.py | 117 +++++++++++---------- 1 file changed, 64 insertions(+), 53 deletions(-) diff --git a/array_api_tests/test_indexing_functions.py b/array_api_tests/test_indexing_functions.py index 7b8c8763..4996932d 100644 --- a/array_api_tests/test_indexing_functions.py +++ b/array_api_tests/test_indexing_functions.py @@ -35,39 +35,43 @@ def test_take(x, data): indices = xp.asarray(_indices, dtype=dh.default_int) note(f"{indices=}") - out = xp.take(x, indices, **kw) - - ph.assert_dtype("take", in_dtype=x.dtype, out_dtype=out.dtype) - ph.assert_shape( - "take", - out_shape=out.shape, - expected=x.shape[:n_axis] + (len(_indices),) + x.shape[n_axis + 1:], - kw=dict( - x=x, - indices=indices, - axis=axis, - ), - ) - out_indices = sh.ndindex(out.shape) - axis_indices = list(sh.axis_ndindex(x.shape, n_axis)) - for axis_idx in axis_indices: - f_axis_idx = sh.fmt_idx("x", axis_idx) - for i in _indices: - f_take_idx = sh.fmt_idx(f_axis_idx, i) - indexed_x = x[axis_idx][i, ...] - for at_idx in sh.ndindex(indexed_x.shape): - out_idx = next(out_indices) - ph.assert_0d_equals( - "take", - x_repr=sh.fmt_idx(f_take_idx, at_idx), - x_val=indexed_x[at_idx], - out_repr=sh.fmt_idx("out", out_idx), - out_val=out[out_idx], - ) - # sanity check - with pytest.raises(StopIteration): - next(out_indices) + repro_snippet = ph.format_snippet(f"xp.take({x!r}, {indices!r}, **kw) with {kw = }") + try: + out = xp.take(x, indices, **kw) + ph.assert_dtype("take", in_dtype=x.dtype, out_dtype=out.dtype) + ph.assert_shape( + "take", + out_shape=out.shape, + expected=x.shape[:n_axis] + (len(_indices),) + x.shape[n_axis + 1:], + kw=dict( + x=x, + indices=indices, + axis=axis, + ), + ) + out_indices = sh.ndindex(out.shape) + axis_indices = list(sh.axis_ndindex(x.shape, n_axis)) + for axis_idx in axis_indices: + f_axis_idx = sh.fmt_idx("x", axis_idx) + for i in _indices: + f_take_idx = sh.fmt_idx(f_axis_idx, i) + indexed_x = x[axis_idx][i, ...] + for at_idx in sh.ndindex(indexed_x.shape): + out_idx = next(out_indices) + ph.assert_0d_equals( + "take", + x_repr=sh.fmt_idx(f_take_idx, at_idx), + x_val=indexed_x[at_idx], + out_repr=sh.fmt_idx("out", out_idx), + out_val=out[out_idx], + ) + # sanity check + with pytest.raises(StopIteration): + next(out_indices) + except Exception as exc: + exc.add_note(repro_snippet) + raise @pytest.mark.unvectorized @pytest.mark.min_version("2024.12") @@ -103,26 +107,33 @@ def test_take_along_axis(x, data): ) note(f"{indices=} {idx_shape=}") - out = xp.take_along_axis(x, indices, **axis_kw) - - ph.assert_dtype("take_along_axis", in_dtype=x.dtype, out_dtype=out.dtype) - ph.assert_shape( - "take_along_axis", - out_shape=out.shape, - expected=x.shape[:n_axis] + (new_len,) + x.shape[n_axis+1:], - kw=dict( - x=x, - indices=indices, - axis=axis, - ), + repro_snippet = ph.format_snippet( + f"xp.take_along_axis({x!r}, {indices!r}, **axis_kw) with {axis_kw = }" ) + try: + out = xp.take_along_axis(x, indices, **axis_kw) + + ph.assert_dtype("take_along_axis", in_dtype=x.dtype, out_dtype=out.dtype) + ph.assert_shape( + "take_along_axis", + out_shape=out.shape, + expected=x.shape[:n_axis] + (new_len,) + x.shape[n_axis+1:], + kw=dict( + x=x, + indices=indices, + axis=axis, + ), + ) - # value test: notation is from `np.take_along_axis` docstring - Ni, Nk = x.shape[:n_axis], x.shape[n_axis+1:] - for ii in sh.ndindex(Ni): - for kk in sh.ndindex(Nk): - a_1d = x[ii + (slice(None),) + kk] - i_1d = indices[ii + (slice(None),) + kk] - o_1d = out[ii + (slice(None),) + kk] - for j in range(new_len): - assert o_1d[j] == a_1d[i_1d[j]], f'{ii=}, {kk=}, {j=}' + # value test: notation is from `np.take_along_axis` docstring + Ni, Nk = x.shape[:n_axis], x.shape[n_axis+1:] + for ii in sh.ndindex(Ni): + for kk in sh.ndindex(Nk): + a_1d = x[ii + (slice(None),) + kk] + i_1d = indices[ii + (slice(None),) + kk] + o_1d = out[ii + (slice(None),) + kk] + for j in range(new_len): + assert o_1d[j] == a_1d[i_1d[j]], f'{ii=}, {kk=}, {j=}' + except Exception as exc: + exc.add_note(repro_snippet) + raise From c9f67727518417f039f879660dd0f5a3866994b9 Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Fri, 21 Nov 2025 15:22:34 +0100 Subject: [PATCH 3/5] ENH: add "repro_snippets" to test_array_object.py --- array_api_tests/test_array_object.py | 176 +++++++++++++++------------ 1 file changed, 99 insertions(+), 77 deletions(-) diff --git a/array_api_tests/test_array_object.py b/array_api_tests/test_array_object.py index af575182..ba34716b 100644 --- a/array_api_tests/test_array_object.py +++ b/array_api_tests/test_array_object.py @@ -86,7 +86,6 @@ def test_getitem(shape, dtype, data): key = data.draw(xps.indices(shape=shape, allow_newaxis=True), label="key") repro_snippet = ph.format_snippet(f"{x!r}[{key!r}]") - try: out = x[key] @@ -109,6 +108,7 @@ def test_getitem(shape, dtype, data): ph.add_note(exc, repro_snippet) raise + @pytest.mark.unvectorized @given( shape=hh.shapes(), @@ -133,28 +133,34 @@ def test_setitem(shape, dtypes, data): value = data.draw(value_strat, label="value") res = xp.asarray(x, copy=True) - res[key] = value - - ph.assert_dtype("__setitem__", in_dtype=x.dtype, out_dtype=res.dtype, repr_name="x.dtype") - ph.assert_shape("__setitem__", out_shape=res.shape, expected=x.shape, repr_name="x.shape") - f_res = sh.fmt_idx("x", key) - if isinstance(value, get_args(Scalar)): - msg = f"{f_res}={res[key]!r}, but should be {value=} [__setitem__()]" - if cmath.isnan(value): - assert xp.isnan(res[key]), msg + + repro_snippet = ph.format_snippet(f"{res!r}[{key!r}] = {value!r}") + try: + res[key] = value + + ph.assert_dtype("__setitem__", in_dtype=x.dtype, out_dtype=res.dtype, repr_name="x.dtype") + ph.assert_shape("__setitem__", out_shape=res.shape, expected=x.shape, repr_name="x.shape") + f_res = sh.fmt_idx("x", key) + if isinstance(value, get_args(Scalar)): + msg = f"{f_res}={res[key]!r}, but should be {value=} [__setitem__()]" + if cmath.isnan(value): + assert xp.isnan(res[key]), msg + else: + assert res[key] == value, msg else: - assert res[key] == value, msg - else: - ph.assert_array_elements("__setitem__", out=res[key], expected=value, out_repr=f_res) - unaffected_indices = set(sh.ndindex(res.shape)) - set(product(*axes_indices)) - for idx in unaffected_indices: - ph.assert_0d_equals( - "__setitem__", - x_repr=f"old {f_res}", - x_val=x[idx], - out_repr=f"modified {f_res}", - out_val=res[idx], - ) + ph.assert_array_elements("__setitem__", out=res[key], expected=value, out_repr=f_res) + unaffected_indices = set(sh.ndindex(res.shape)) - set(product(*axes_indices)) + for idx in unaffected_indices: + ph.assert_0d_equals( + "__setitem__", + x_repr=f"old {f_res}", + x_val=x[idx], + out_repr=f"modified {f_res}", + out_val=res[idx], + ) + except Exception as exc: + exc.add_note(repro_snippet) + raise @pytest.mark.unvectorized @@ -178,29 +184,34 @@ def test_getitem_masking(shape, data): x[key] return - out = x[key] + repro_snippet = ph.format_snippet(f"out = {x!r}[{key!r}]") + try: + out = x[key] - ph.assert_dtype("__getitem__", in_dtype=x.dtype, out_dtype=out.dtype) - if key.ndim == 0: - expected_shape = (1,) if key else (0,) - expected_shape += x.shape - else: - size = int(xp.sum(xp.astype(key, xp.uint8))) - expected_shape = (size,) + x.shape[key.ndim :] - ph.assert_shape("__getitem__", out_shape=out.shape, expected=expected_shape) - if not any(s == 0 for s in key.shape): - assume(key.ndim == x.ndim) # TODO: test key.ndim < x.ndim scenarios - out_indices = sh.ndindex(out.shape) - for x_idx in sh.ndindex(x.shape): - if key[x_idx]: - out_idx = next(out_indices) - ph.assert_0d_equals( - "__getitem__", - x_repr=f"x[{x_idx}]", - x_val=x[x_idx], - out_repr=f"out[{out_idx}]", - out_val=out[out_idx], - ) + ph.assert_dtype("__getitem__", in_dtype=x.dtype, out_dtype=out.dtype) + if key.ndim == 0: + expected_shape = (1,) if key else (0,) + expected_shape += x.shape + else: + size = int(xp.sum(xp.astype(key, xp.uint8))) + expected_shape = (size,) + x.shape[key.ndim :] + ph.assert_shape("__getitem__", out_shape=out.shape, expected=expected_shape) + if not any(s == 0 for s in key.shape): + assume(key.ndim == x.ndim) # TODO: test key.ndim < x.ndim scenarios + out_indices = sh.ndindex(out.shape) + for x_idx in sh.ndindex(x.shape): + if key[x_idx]: + out_idx = next(out_indices) + ph.assert_0d_equals( + "__getitem__", + x_repr=f"x[{x_idx}]", + x_val=x[x_idx], + out_repr=f"out[{out_idx}]", + out_val=out[out_idx], + ) + except Exception as exc: + exc.add_note(repro_snippet) + raise @pytest.mark.unvectorized @@ -213,38 +224,44 @@ def test_setitem_masking(shape, data): ) res = xp.asarray(x, copy=True) - res[key] = value - - ph.assert_dtype("__setitem__", in_dtype=x.dtype, out_dtype=res.dtype, repr_name="x.dtype") - ph.assert_shape("__setitem__", out_shape=res.shape, expected=x.shape, repr_name="x.dtype") - scalar_type = dh.get_scalar_type(x.dtype) - for idx in sh.ndindex(x.shape): - if key[idx]: - if isinstance(value, get_args(Scalar)): - ph.assert_scalar_equals( - "__setitem__", - type_=scalar_type, - idx=idx, - out=scalar_type(res[idx]), - expected=value, - repr_name="modified x", - ) + + repro_snippet = ph.format_snippet(f"{res}[{key!r}] = {value!r}") + try: + res[key] = value + + ph.assert_dtype("__setitem__", in_dtype=x.dtype, out_dtype=res.dtype, repr_name="x.dtype") + ph.assert_shape("__setitem__", out_shape=res.shape, expected=x.shape, repr_name="x.dtype") + scalar_type = dh.get_scalar_type(x.dtype) + for idx in sh.ndindex(x.shape): + if key[idx]: + if isinstance(value, get_args(Scalar)): + ph.assert_scalar_equals( + "__setitem__", + type_=scalar_type, + idx=idx, + out=scalar_type(res[idx]), + expected=value, + repr_name="modified x", + ) + else: + ph.assert_0d_equals( + "__setitem__", + x_repr="value", + x_val=value, + out_repr=f"modified x[{idx}]", + out_val=res[idx] + ) else: ph.assert_0d_equals( "__setitem__", - x_repr="value", - x_val=value, + x_repr=f"old x[{idx}]", + x_val=x[idx], out_repr=f"modified x[{idx}]", out_val=res[idx] ) - else: - ph.assert_0d_equals( - "__setitem__", - x_repr=f"old x[{idx}]", - x_val=x[idx], - out_repr=f"modified x[{idx}]", - out_val=res[idx] - ) + except Exception as exc: + exc.add_note(repro_snippet) + raise # ### Fancy indexing ### @@ -309,15 +326,20 @@ def _test_getitem_arrays_and_ints(shape, data, idx_max_dims): key.append(data.draw(st.integers(-shape[i], shape[i]-1))) key = tuple(key) - out = x[key] + repro_snippet = ph.format_snippet(f"out = {x!r}[{key!r}]") + try: + out = x[key] - arrays = [xp.asarray(k) for k in key] - bcast_shape = sh.broadcast_shapes(*[arr.shape for arr in arrays]) - bcast_key = [xp.broadcast_to(arr, bcast_shape) for arr in arrays] + arrays = [xp.asarray(k) for k in key] + bcast_shape = sh.broadcast_shapes(*[arr.shape for arr in arrays]) + bcast_key = [xp.broadcast_to(arr, bcast_shape) for arr in arrays] - for idx in sh.ndindex(bcast_shape): - tpl = tuple(k[idx] for k in bcast_key) - assert out[idx] == x[tpl], f"failing at {idx = } w/ {key = }" + for idx in sh.ndindex(bcast_shape): + tpl = tuple(k[idx] for k in bcast_key) + assert out[idx] == x[tpl], f"failing at {idx = } w/ {key = }" + except Exception as exc: + exc.add_note(repro_snippet) + raise def make_scalar_casting_param( From 0c73a6f1cec8b7585bc325ae244e3ea843b35471 Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Fri, 21 Nov 2025 15:23:37 +0100 Subject: [PATCH 4/5] Update .git-blame-ignore-revs for whitespace heavy commits --- .git-blame-ignore-revs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 4541bd36..eaeedfd4 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -7,3 +7,8 @@ e807ffe526c7330691e8f39d31347dc2b3106de3 bd42e84d2e5aae26ade8d70384e74effd1de89cb f7e822883b7e24b5aa540e2413759a85128b42ef a37f348ba27b6818e92fda8aee2406c653c671ea +# gh-396 +ec5a3b4e185c262b0a5f5b1631b84a09f766d80e +9058908b58ce627467ac34e768098a25f5863d31 +c80e1823c2e738381ca02f27cea1e2b89dde0ac5 + From 5acac26b36ca4215a9a857a318fbec4ebf86f73f Mon Sep 17 00:00:00 2001 From: Evgeni Burovski Date: Mon, 1 Dec 2025 16:23:31 +0100 Subject: [PATCH 5/5] MAINT: python 3.10 compatible add_note cf https://github.com/data-apis/array-api-tests/pull/398 --- array_api_tests/test_array_object.py | 8 ++++---- array_api_tests/test_indexing_functions.py | 4 ++-- array_api_tests/test_utility_functions.py | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/array_api_tests/test_array_object.py b/array_api_tests/test_array_object.py index ba34716b..8337cd86 100644 --- a/array_api_tests/test_array_object.py +++ b/array_api_tests/test_array_object.py @@ -159,7 +159,7 @@ def test_setitem(shape, dtypes, data): out_val=res[idx], ) except Exception as exc: - exc.add_note(repro_snippet) + ph.add_note(exc, repro_snippet) raise @@ -210,7 +210,7 @@ def test_getitem_masking(shape, data): out_val=out[out_idx], ) except Exception as exc: - exc.add_note(repro_snippet) + ph.add_note(exc, repro_snippet) raise @@ -260,7 +260,7 @@ def test_setitem_masking(shape, data): out_val=res[idx] ) except Exception as exc: - exc.add_note(repro_snippet) + ph.add_note(exc, repro_snippet) raise @@ -338,7 +338,7 @@ def _test_getitem_arrays_and_ints(shape, data, idx_max_dims): tpl = tuple(k[idx] for k in bcast_key) assert out[idx] == x[tpl], f"failing at {idx = } w/ {key = }" except Exception as exc: - exc.add_note(repro_snippet) + ph.add_note(exc, repro_snippet) raise diff --git a/array_api_tests/test_indexing_functions.py b/array_api_tests/test_indexing_functions.py index 4996932d..64e4261f 100644 --- a/array_api_tests/test_indexing_functions.py +++ b/array_api_tests/test_indexing_functions.py @@ -70,7 +70,7 @@ def test_take(x, data): with pytest.raises(StopIteration): next(out_indices) except Exception as exc: - exc.add_note(repro_snippet) + ph.add_note(exc, repro_snippet) raise @pytest.mark.unvectorized @@ -135,5 +135,5 @@ def test_take_along_axis(x, data): for j in range(new_len): assert o_1d[j] == a_1d[i_1d[j]], f'{ii=}, {kk=}, {j=}' except Exception as exc: - exc.add_note(repro_snippet) + ph.add_note(exc, repro_snippet) raise diff --git a/array_api_tests/test_utility_functions.py b/array_api_tests/test_utility_functions.py index 9d136dcb..eefee250 100644 --- a/array_api_tests/test_utility_functions.py +++ b/array_api_tests/test_utility_functions.py @@ -38,7 +38,7 @@ def test_all(x, data): ph.assert_scalar_equals("all", type_=scalar_type, idx=out_idx, out=result, expected=expected, kw=kw) except Exception as exc: - exc.add_note(repro_snippet) + ph.add_note(exc, repro_snippet) raise @@ -71,7 +71,7 @@ def test_any(x, data): ph.assert_scalar_equals("any", type_=scalar_type, idx=out_idx, out=result, expected=expected, kw=kw) except Exception as exc: - exc.add_note(repro_snippet) + ph.add_note(exc, repro_snippet) raise @@ -111,7 +111,7 @@ def test_diff(x, data): l[n_axis] += 1 assert out[idx] == x[tuple(l)] - x[idx], f"diff failed with {idx = }" except Exception as exc: - exc.add_note(repro_snippet) + ph.add_note(exc, repro_snippet) raise @@ -158,6 +158,6 @@ def test_diff_append_prepend(x, data): for idx in sh.ndindex(out.shape): assert out[idx] == out_1[idx], f"{idx = }" except Exception as exc: - exc.add_note(repro_snippet) + ph.add_note(exc, repro_snippet) raise