Skip to content

Treat minus as a number separator in FLOAT_CMP - #328

Open
abhishekcpp007 wants to merge 2 commits into
scientific-python:mainfrom
abhishekcpp007:fix/float-cmp-negative-imag
Open

abhishekcpp007 wants to merge 2 commits into
scientific-python:mainfrom
abhishekcpp007:fix/float-cmp-negative-imag

Conversation

@abhishekcpp007

Copy link
Copy Markdown

In front_sep = r'\s|[*+-,<=(\[]' the +-, is a character range from + to ,, so - isn't a separator. Numbers right after a - aren't found, and a complex repr with a negative imaginary part fails under FLOAT_CMP:

>>> complex(1.5, 2.50000001)  # doctest: +FLOAT_CMP
(1.5+2.5j)
>>> complex(1.5, -2.50000001)  # doctest: +FLOAT_CMP
(1.5-2.5j)

The first passes and the second fails with Got: (1.5-2.50000001j). Escaping the - fixes it. A flipped sign like (1.5+2.5j) vs (1.5-2.5j) still fails.

Added test_float_cmp_complex next to test_float_cmp_dict and a changelog entry.

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