-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Equality tests on floats: add support for math.isclose() and numpy.isclose() #5977
Comments
Thanks for the suggestion. I've added this as a feature request. If you'd like to contribute, the high level Numba extension API |
This comment appears to be spam since it is out of context and doesn't make sense in the current conversation. My advice is: DO NOT CLICK THE LINK since it may very well redirect you to malware. I have reported the user @codeFairOfficial to the GitHub abuse program as outlined here: https://docs.github.com/en/github/building-a-strong-community/reporting-abuse-or-spam |
This is not spam, but we are so sorry to intrude! We actually are company looking to find new ways to get issues resolved quickly. We currently have a team of programmers finding issues that they could help get fixed. Our appologies for coming off as spam/malware, we will take this into account next time. I have deleted the original post |
@codeFairOfficial thank you for following up on this. We (the maintainers) always do welcome new members to our community, especially when it revolves around offering commercial services related to Numba. To avoid any false-positive classifications of your submissions, I would suggest introducing yourselves, your company and maybe your programmers on our Community forum at: https://numba.discourse.group/ -- this would also allow you to discuss with our community, your approach to finding issues to resolve in order to find consensus on a good process. For example, it will make sense to discuss with users about their needs in the issue itself rather than linking to an external service since "random hyperlinks" are always a cause of suspicion. |
@esc thank you for the feedback, we couldn't agree more. We will reach out to your community forum and discuss before posting any further. |
@codeFairOfficial thank you! |
Hi, I also prefer to see a long URL rather than a short one. At least we
know what domain we are reaching.
Le ven. 5 févr. 2021 à 15:51, esc <notifications@github.com> a écrit :
… @codeFairOfficial <https://github.com/codeFairOfficial> thank you!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5977 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFTXC55KEVCHCSRTJA6OHJLS5QAV7ANCNFSM4OWSHSGQ>
.
|
Similar to #6857, I think >>> import numpy as np
>>> import numba as nb
>>> nb.__version__
'0.55.1'
>>> def g(a, b):
... return np.isclose(a, b)
...
>>> g(np.array([1.1, 2.2, 3.3]), np.array([1.1+1e-12, 2.0, 3.3+1e-12]))
array([ True, False, True]) Similarly for >>> import math
>>> def h(a, b):
... return math.isclose(a, b)
...
>>> h(1.1, 1.1+1e-12)
True
>>> h(1.1, 1.0)
False So I think this issue can be closed. |
@jpivarski thank you for the heads up! |
Sorry—I have to take that back! np.isclose and math.isclose are not implemented in Numba. In my tests, I forgot to add the |
This issue should be reopened! |
Of course, no problem! Errare humanum est! 😘 |
I'd like to have this feature as well. |
Feature request
When testing the equality of two floating point numbers, it’s good practices to rely on approximations (e.g.,
abs(a - b) < epsilon
) rather than on exact/bit-to-bit comparison.In Python we can use
math.isclose
ornumpy.isclose
to do such tests. These functions are a bit different but both can be equally useful. Unlike the built-inmath.isclose
,numpy.isclose
is not symmetric ina
andb
– it assumesb
is the reference value – so thatisclose(a, b)
might be different fromisclose(b, a)
.math
andnumpy
libraries).equal_nan
if existing) because each use case can have specific parameters.I could not find an issue about that when searching issues with keywords "isclose", "float comparison", "float equality".
The text was updated successfully, but these errors were encountered: