Skip to content
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

Eq versus == behavior following Float "integer" is_integer changes #26146

Open
cbm755 opened this issue Jan 29, 2024 · 4 comments
Open

Eq versus == behavior following Float "integer" is_integer changes #26146

cbm755 opened this issue Jan 29, 2024 · 4 comments
Labels
core floats Needs Decision This needs discussion to resolve an undecided issue before further work can be done.

Comments

@cbm755
Copy link
Contributor

cbm755 commented Jan 29, 2024

Float("2", 32) == Float("2", 64) is now False after #25875.

But Eq(Float("2", 32), Float("2", 64)) is still True. IIRC, we want structural equality to imply mathematical equality (in many perhaps most cases). But of course not the other way around.

@smichr do you think that Eq(Float2, 32), Float(2, 64)) should also be non-truthy?


In seems this would also be consistent with this behaviour:

>>> n = Symbol('n', integer=True)
>>> Eq(n, Float("3", 32))
False
@cbm755 cbm755 added core floats Needs Decision This needs discussion to resolve an undecided issue before further work can be done. labels Jan 29, 2024
@oscarbenjamin
Copy link
Contributor

What == should do is clear because it is for structural equality. Eq is a whole other can of worms though.

@asmeurer
Copy link
Member

In seems this would also be consistent with this behaviour:

That incorrect behavior has been fixed:

>>> n = Symbol('n', integer=True)
>>> Eq(n, Float("3", 32))
Eq(n, 3.0)

@asmeurer
Copy link
Member

I'm not sure what the behavior here should be. Whatever it does, the behavior for Eq(Rational, Float) should work the same as Eq(Float, Float) for floats of different precision. My initial feeling is that they should return True, as they currently do. Returning False would be bad, but staying unevaluated is an option.

@asmeurer
Copy link
Member

That incorrect behavior has been fixed:

The discussions around that fix are also relevant here #23731 #25856 #25875 #25865 #25864

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core floats Needs Decision This needs discussion to resolve an undecided issue before further work can be done.
Projects
None yet
Development

No branches or pull requests

3 participants