Skip to content

BUG: work around some names not available in 2022.12 #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions array_api_tests/test_operators_and_elementwise_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1794,19 +1794,26 @@ def _check_binary_with_scalars(func_data, x1x2):
def _filter_zero(x):
return x != 0 if dh.is_scalar(x) else (not xp.any(x == 0))

# workarounds for xp.copysign etc only available in 2023.12
# Without it, test suite fails to import with ARRAY_API_VERSION=2022.12
_xp_copysign = getattr(xp, "copysign", None)
_xp_hypot = getattr(xp, "hypot", None)
_xp_maximum = getattr(xp, "maximum", None)
_xp_minimum = getattr(xp, "minimum", None)


@pytest.mark.min_version("2024.12")
@pytest.mark.parametrize('func_data',
# xp_func, name, refimpl, kwargs, expected_dtype
[
(xp.add, "add", operator.add, {}, None),
(xp.atan2, "atan2", math.atan2, {}, None),
(xp.copysign, "copysign", math.copysign, {}, None),
(_xp_copysign, "copysign", math.copysign, {}, None),
(xp.divide, "divide", operator.truediv, {"filter_": lambda s: s != 0}, None),
(xp.hypot, "hypot", math.hypot, {}, None),
(_xp_hypot, "hypot", math.hypot, {}, None),
(xp.logaddexp, "logaddexp", logaddexp_refimpl, {}, None),
(xp.maximum, "maximum", max, {'strict_check': True}, None),
(xp.minimum, "minimum", min, {'strict_check': True}, None),
(_xp_maximum, "maximum", max, {'strict_check': True}, None),
(_xp_minimum, "minimum", min, {'strict_check': True}, None),
(xp.multiply, "mul", operator.mul, {}, None),
(xp.subtract, "sub", operator.sub, {}, None),

Expand Down