Skip to content

gh-149924: add tests to improve coverage for test_complex_special#150938

Open
Aniketsy wants to merge 2 commits into
python:mainfrom
Aniketsy:fix-149924
Open

gh-149924: add tests to improve coverage for test_complex_special#150938
Aniketsy wants to merge 2 commits into
python:mainfrom
Aniketsy:fix-149924

Conversation

@Aniketsy
Copy link
Copy Markdown
Contributor

@Aniketsy Aniketsy commented Jun 5, 2026

Comment thread Lib/test/test_cmath.py Outdated
Comment on lines +593 to +611
self.assertIsNotClose(complex(INF, INF), complex(-INF, -INF))
self.assertIsNotClose(complex(INF, INF), complex(INF, -INF))
self.assertIsNotClose(complex(INF, INF), complex(-INF, INF))
self.assertIsNotClose(complex(-INF, INF), complex(INF, -INF))
self.assertIsNotClose(complex(NAN, NAN), complex(NAN, NAN))
self.assertIsNotClose(complex(NAN, 0), complex(NAN, 0))
self.assertIsNotClose(complex(0, NAN), complex(0, NAN))
self.assertIsNotClose(complex(INF, NAN), complex(INF, NAN))
self.assertIsNotClose(complex(NAN, INF), complex(NAN, INF))
self.assertIsNotClose(complex(-INF, NAN), complex(-INF, NAN))
self.assertIsNotClose(complex(NAN, -INF), complex(NAN, -INF))
self.assertIsNotClose(complex(INF, INF), complex(1, 1))
self.assertIsNotClose(complex(-INF, -INF), complex(1, 1))
self.assertIsNotClose(complex(INF, 0), complex(0, 0))
self.assertIsNotClose(complex(0, INF), complex(0, 0))
self.assertIsClose(complex(INF, INF), complex(INF, INF))
self.assertIsClose(complex(-INF, -INF), complex(-INF, -INF))
self.assertIsClose(complex(INF, -INF), complex(INF, -INF))
self.assertIsClose(complex(-INF, INF), complex(-INF, INF))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are going for completeness, consider using itertools.combinations() to generate arguments.

Test that (1) nan's aren't close to anything and (2) inf's are only close to themselves. Note that complex nan's can be infinite. In this case (1) holds.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are going for completeness, consider using itertools.combinations() to generate arguments.

Test that (1) nan's aren't close to anything and (2) inf's are only close to themselves. Note that complex nan's can be infinite. In this case (1) holds.

thanks , this looks more clean 👍

@skirpichev skirpichev assigned skirpichev and unassigned skirpichev Jun 5, 2026
@skirpichev skirpichev self-requested a review June 5, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase test coverage for isclose() function with edge cases for special complex numbers

2 participants