Fix complex π expression parsing in special case tests#7
Merged
ev-br merged 3 commits intocopilot/add-complex-special-case-supportfrom Jan 15, 2026
Merged
Conversation
- Updated r_complex_value regex to handle πj/N and NπJ/M patterns - Modified parse_complex_value to extract imaginary coefficient from both πj and plain formats - Updated parse_complex_result to use approximate equality for π-based values - Test failures reduced from 23 to 9 (14 failures fixed) Co-authored-by: ev-br <2133832+ev-br@users.noreply.github.com>
…ogic - Updated regex to match multi-digit denominators (\d+) - Fixed inconsistent j stripping logic in parse_complex_value - Added helper function for component comparison to eliminate code duplication - Fixed capitalization in docstring examples Co-authored-by: ev-br <2133832+ev-br@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix complex special case parsing implementation
Fix complex π expression parsing in special case tests
Jan 15, 2026
7293ac8
into
copilot/add-complex-special-case-support
2 of 10 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #3 added infrastructure for complex special case parsing but failed to handle π expressions in imaginary components like
πj/2,3πj/4, causing 14 test failures.Changes
Regex pattern
r_complex_valueto match two formats: πj expressions wherejis embedded (πj/2) and plain values followed byj(NaN j)\dto\d+to support multi-digit denominatorsParse logic
parse_complex_value: Extract coefficients from both πj format (stripj) and plain format (strip trailingj)parse_complex_result: Detect π symbols and use approximate equality (make_rough_eq) for π-based values_check_component_with_tolerancehelper to eliminate duplicated comparison logicBug fix
make_andoperator (was usingorinstead ofand)Example
Before:
After:
Results
Remaining 10 failures are unrelated implementation bugs in
array_api_strict(e.g.,expm1returning NaN instead of spec values).Original prompt
Fix PR #3: Implement Complete Complex Special Case Parsing
Current Problem
PR #3 (branch
copilot/add-complex-special-case-support) claims to add complex special case parsing but does not actually work. Running tests shows:AssertionError: out=1.5707963267948966j, but should be +0 + πj/2Success Criteria
After fixing, running
ARRAY_API_TESTS_MODULE=array_api_strict pytest array_api_tests/test_special_cases.py::test_unarymust:Root Cause Analysis
The PR description claims these functions were added, but they are missing from the actual code:
parse_complex_value()- to parse"+0 + πj/2"intocomplex(0, π/2)parse_complex_cond()- to parse"If a is +0 and b is +0"conditionsparse_complex_result()- to parse complex result expressionsmake_strict_eq_complex()- to check complex equality with sign awarenessparse_unary_case_block()test_unary()Required Implementation
1. Add Complex Value Parser (after line 493)
2. Add Complex Equality Checker (after parse_complex_value)
3. Add Complex Condition Parser (after make_strict_eq_complex)
4. Add Complex Result Parser (after parse_complex_cond)