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.
@rgommers
Copy link
Member

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

Thanks @ev-br. Since it's the first such PR, I had a look - in my opinion this declaration and the level of visibility on how this code was generated is nice, and acceptable for this project. Given that this project is "advanced plumbing", I don't have any concerns about copyright, or extra review load from AI-generated contributions (you did the steering and review already).

Copilot AI and others added 2 commits January 19, 2026 13:29
- Update r_complex_value regex to match ± in sign positions
- Normalize ± to + in parse_complex_value() function
- Detect ± symbols in parse_complex_result() to set unspecified sign flags
- Results: 246 passed (+4), 45 warnings (-4)

Handle spaces after ± symbol in complex value parsing

Update regex to allow optional whitespace between sign and value: ([±+-]?)\s*
This now handles cases like "± 0 + 0j" in addition to "±0 + 0j"
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.

2 participants