Skip to content

Commit 5054097

Browse files
Copilotev-br
andcommitted
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" Co-authored-by: ev-br <2133832+ev-br@users.noreply.github.com>
1 parent e463219 commit 5054097

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

array_api_tests/test_special_cases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,9 @@ class UnaryCase(Case):
751751
r_complex_case = re.compile(r"If ``a`` is (.+) and ``b`` is (.+), the result is (.+)")
752752
# Matches complex values like "+0 + 0j", "NaN + NaN j", "infinity + NaN j", "πj/2", "3πj/4"
753753
# Two formats: 1) πj/N expressions where j is part of the coefficient, 2) plain values followed by j
754-
# Also handles ± symbol for unspecified signs
754+
# Also handles ± symbol for unspecified signs (with or without spaces after the sign)
755755
r_complex_value = re.compile(
756-
r"([±+-]?)([^\s]+)\s*([±+-])\s*(?:(\d*πj(?:/\d+)?)|([^\s]+))\s*j?"
756+
r"([±+-]?)\s*([^\s]+)\s*([±+-])\s*(?:(\d*πj(?:/\d+)?)|([^\s]+))\s*j?"
757757
)
758758

759759

0 commit comments

Comments
 (0)