python / python/cpython

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

Open
#149,924 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

tests
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

In Lib/test/test_cmath.py, the isclose() function misses certain test cases for special complex numbers with infinity and Nan. As docs tell:

-inf, inf and NaN behave similarly to the IEEE 754 Standard. 
That is, NaN is not close to anything, even itself. 
inf and -inf are only close to themselves. 

This applies for complex numbers as well (inf + infj , -inf - infj and NaN + NaNj behave in the same way).

Linked PRs
  • gh-149923
  • gh-149948
  • gh-150938

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Lib/test/test_cmath.py and inspect the existing isclose() tests and the documented behavior for infinity, negative infinity, and NaN. Add coverage for the stated special complex-number cases, then run the cmath test file to confirm the expected results.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.