Skip to content

Commit 8694dc6

Browse files
committed
ENH: add testing of reciprocal
1 parent d4d6eee commit 8694dc6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

array_api_tests/test_operators_and_elementwise_functions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,22 @@ def test_real(x):
15671567
unary_assert_against_refimpl("real", x, out, operator.attrgetter("real"))
15681568

15691569

1570+
@pytest.mark.min_version("2024.12")
1571+
@given(hh.arrays(dtype=hh.floating_dtypes, shape=hh.shapes(), elements=finite_kw))
1572+
def test_reciprocal(x):
1573+
out = xp.reciprocal(x)
1574+
ph.assert_dtype("reciprocal", in_dtype=x.dtype, out_dtype=out.dtype)
1575+
ph.assert_shape("reciprocal", out_shape=out.shape, expected=x.shape)
1576+
refimpl = lambda x: 1.0 / x
1577+
unary_assert_against_refimpl(
1578+
"reciprocal",
1579+
x,
1580+
out,
1581+
refimpl,
1582+
strict_check=True,
1583+
)
1584+
1585+
15701586
@pytest.mark.skip(reason="flaky")
15711587
@pytest.mark.parametrize("ctx", make_binary_params("remainder", dh.real_dtypes))
15721588
@given(data=st.data())

0 commit comments

Comments
 (0)