isclose behavior on non-finite complex values seems incorrect
See original GitHub issueFor example:
np.isclose(complex(float('inf'), 0), complex(float('inf'), 0))
: False
np.isclose(complex(1, float('inf')), complex(1, float('nan')), equal_nan=True)
: True
In the first case it seems like the same number should be close to itself, and in the latter case I think the numbers should not be close since NaN is not close to anything.
Python’s cmath.isclose behavior appears to demand that complex numbers containing -inf or inf must be identical to be close. It does not support equal_nan so complex numbers containing NaN are never close to other complex numbers. If equal_nan is True I would expect NaNs to act like infinities and require the numbers be identical to be “close.”
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (15 by maintainers)
Top Results From Across the Web
Covert Modality in Non-Finite Contexts - ScholarlyCommons
This dissertation investigates the distribution and interpretation of covert modality. Three environments where covert modality appears are analyzed. These ...
Read more >Why does math.isclose() fail to detect minor differences ...
The above code was run with Python 3.5.2. UPDATE 1: It seems that a similar behavior occurs when using very large float values:...
Read more >Introduction, split-Infl, etc. The enterprise (reminder)
And, if Agr is transparent (French), no problem, move away. What about the French restriction on nonfinite lexical verb movement to I? Pollock's...
Read more >Zero-inflated model: non-finite value supplied by optim [closed]
The model with quarter as predictor looks like this: cr_f1c = formula(cr ~ depth + habtype2 + quarter + hurseason + year +...
Read more >Eigenvalues and eigenvectors - MATLAB eig
Generalized eigenvalue problem input matrix, specified as a square matrix of real or complex values. B must be the same size as A...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
😄 sorry, my bad.
yes for inf it looks like it will be a breaking change, though i find the following behavior inconsistent in numpy:
Oh, I had forgotten after all this discussion that the original issue post already mentioned
cmath
and this behaviour. We need to decide what we think is best, and then open abpo
and maybe document the differences. I personally think the python behaviour with partial complexinf
may just be an oversight (although python is in slightly different situations about giving warnings)?