Skip to content

test_special_cases uses incorrect test case for copysign with NaN #264

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

Closed
ndgrigorian opened this issue May 16, 2024 · 1 comment · Fixed by #268
Closed

test_special_cases uses incorrect test case for copysign with NaN #264

ndgrigorian opened this issue May 16, 2024 · 1 comment · Fixed by #268

Comments

@ndgrigorian
Copy link

The spec splits copysign behavior into x1_1 is not NaN cases and x1_i is NaN cases. The special cases parser doesn't handle this properly, leading to incorrect test case generation:

In [3]: import array_api_tests.test_special_cases as tsc

In [4]: copysign_cases = [p.values[-1] for p in tsc.binary_params if p.values[0] == "copysign"]

In [5]: copysign_cases
Out[5]:
[BinaryCase(<x2_i < 0 -> NaN>),
 BinaryCase(<x2_i is -0 -> NaN>),
 BinaryCase(<x2_i is +0 -> NaN>),
 BinaryCase(<x2_i > 0 -> NaN>)]

In [6]: py_nan = float("nan")

In [7]: copysign_cases[0].check_result(1.0, -1.0, -1.0)
Out[7]: False

In [8]: copysign_cases[0].check_result(1.0, -1.0, py_nan)
Out[8]: True

In [9]: copysign_cases[1].check_result(1.0, -0.0, -1.0)
Out[9]: False

In [10]: copysign_cases[1].check_result(1.0, -0.0, py_nan)
Out[10]: True

In [11]: copysign_cases[2].check_result(-1.0, +0.0, 1.0)
Out[11]: False

In [12]: copysign_cases[2].check_result(-1.0, +0.0, py_nan)
Out[12]: True

In [13]: copysign_cases[3].check_result(-1.0, +1.0, 1.0)
Out[13]: False

In [14]: copysign_cases[3].check_result(-1.0, +1.0, py_nan)
Out[14]: True
@asmeurer
Copy link
Member

Fixed at data-apis/array-api#806

asmeurer added a commit to asmeurer/array-api-tests that referenced this issue May 23, 2024
This fixes some issues with the stubs.

Fixes data-apis#264
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants