Skip to content

Commit 889d1dc

Browse files
committed
ENH: test yet more binary functions with arrays and python scalars
- binary_{and,or,xor}
1 parent 6aa369c commit 889d1dc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

array_api_tests/test_operators_and_elementwise_functions.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,3 +1834,21 @@ def test_binary_with_scalars_real(func_data, x1x2):
18341834
def test_binary_with_scalars_bool(func_data, x1x2):
18351835
_check_binary_with_scalars(func_data, x1x2)
18361836

1837+
1838+
@pytest.mark.min_version("2024.12")
1839+
@pytest.mark.parametrize('func_data',
1840+
# xp_func, name, refimpl, kwargs, expected_dtype
1841+
[
1842+
(xp.bitwise_and, "bitwise_and", operator.and_, {}, None),
1843+
(xp.bitwise_or, "bitwise_or", operator.or_, {}, None),
1844+
(xp.bitwise_xor, "bitwise_xor", operator.xor, {}, None),
1845+
],
1846+
ids=lambda func_data: func_data[1] # use names for test IDs
1847+
)
1848+
@given(x1x2=hh.array_and_py_scalar([xp.int32]))
1849+
def test_binary_with_scalars_bitwise(func_data, x1x2):
1850+
xp_func, name, refimpl, kwargs, expected = func_data
1851+
# repack the refimpl
1852+
refimpl_ = lambda l, r: mock_int_dtype(refimpl(l, r), xp.int32 )
1853+
_check_binary_with_scalars((xp_func, name, refimpl_, kwargs,expected), x1x2)
1854+

0 commit comments

Comments
 (0)