Skip to content

Conversation

@ev-br
Copy link
Member

@ev-br ev-br commented Jan 16, 2026

"stub" docstrings include "special cases":

if x_i is +infinity, sqrt(x_i) is +infinity etc

test_special_cases parses these statements from docstrings and makes them into tests cases.

So far, parsing only worked for real value cases, and failed for complex-valued cases:

For complex floating-point operands, let a = real(x_i), b = imag(x_i), and
If a is either +0 or -0 and b is +0, the result is +0 + 0j.

These stanzas simply generate "case for {func} is not machine-readable" UserWarnings. Quite a wall of them.

Therefore, we update parsing and testing code to take these complex-valued cases into accout.
For now, we only consider unary functions.

The effect is that

$ ARRAY_API_TESTS_MODULE=array_api_compat.torch pytest array_api_tests/test_special_cases.py::test_unary

generates

  • "128 passed, 177 warnings in 0.78s" on master
  • "11 failed, 241 passed, 49 warnings in 1.82s" on this branch

So that there are new failures (from new complex-valued cases) but we have 128 less warnings.


NB: this pull request is generated by Copilot. The original prompt and subsequent back-and-forths are at ev-br#3

"stub" docstrings include "special cases":

> `if x_i is +infinity, sqrt(x_i) is +infinity` etc

`test_special_cases` parses these statements from docstrings and makes them
into tests cases.

So far, parsing only worked for real value cases, and failed for complex-valued
cases:

> For complex floating-point operands, let a = real(x_i), b = imag(x_i), and
> `If a is either +0 or -0 and b is +0, the result is +0 + 0j.`

These stanzas simply generate "case for {func} is not machine-readable" `UserWarning`s.
Quite a wall of them.

Therefore, we update parsing and testing code to take these complex-valued
cases into accout.
For now, we only consider unary functions.

The effect is:

$ ARRAY_API_TESTS_MODULE=array_api_compat.torch pytest array_api_tests/test_special_cases.py::test_unary

generates
- "128 passed, 177 warnings in 0.78s" on master
- "11 failed, 241 passed, 49 warnings in 1.82s" on this branch

So that there are new failures (from new complex-valued cases) but we 128 less warnings.
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 this pull request may close these issues.

1 participant