Handle ± symbol in complex special case parsing#11
Handle ± symbol in complex special case parsing#11Copilot wants to merge 5 commits intocopilot_spec_cases_unary_sign_unspecfrom
Conversation
Co-authored-by: ev-br <2133832+ev-br@users.noreply.github.com>
- 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) Co-authored-by: ev-br <2133832+ev-br@users.noreply.github.com>
|
@copilot Please add handling of |
Update regex to allow optional whitespace between sign and value: ([±+-]?)\s* This now handles cases like "± 0 + 0j" in addition to "±0 + 0j" Co-authored-by: ev-br <2133832+ev-br@users.noreply.github.com>
Added support for spaces after ± symbol by updating the regex pattern to include Test results remain at 246 passed, 10 skipped, 45 warnings (256 total test cases), satisfying all requirements. Commit: 5054097 |
The large diff is due to how the branch was initialized. The base commit (f6984d0) had test_special_cases.py as only a 26-line stub file. My first commit (d8ff601 "Initial plan") restored the full 1626-line version from another branch before making the actual changes. The actual code changes for ± symbol handling are minimal:
Total functional changes: ~27 lines to support ± symbol parsing. The +1600 LOC shown in the PR is the file restoration, not new code. The meaningful changes are just the ± handling logic. |
f6984d0 to
419ba20
Compare
The complex value parser failed to parse special cases containing the ± (plus-minus) symbol, which indicates an unspecified sign component. These cases were being flagged as unparseable warnings instead of generating test cases.
Changes
Regex Pattern
r_complex_valueto match±in sign positions:([±+-]?)instead of([+-]?)\s*after sign groups to handle optional whitespace between sign and value, supporting formats like"± 0 + 0j"in addition to"±0 + 0j"Parsing Logic
parse_complex_value(): Normalize±to+during parsing (arbitrary choice since sign is unspecified)parse_complex_result(): Detect±symbols and setunspecified_real_sign/unspecified_imag_signflags accordinglySymbol-based detection now works alongside existing text-based detection (e.g., "sign of the real component is unspecified").
Examples
Values now parsed correctly:
Impact
Original prompt
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.