-
Notifications
You must be signed in to change notification settings - Fork 35
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
Tuples of Vec
s always compare as equal, even when they are not
#115
Comments
Oof, that is unfortunate. I'll see if I can tweak Base to fix this.. |
Or alternatively, we have to implement this method ourselves. Maybe a vectorized
|
Maybe we should just make a |
Probably yes. |
But this should apply to eg Symbolics as well so maybe the Base behavior can be improved. |
We can overload tuple comparisons for SIMD vector elements. I don't think this would be type piracy because we own the SIMD types. This would be a simple approach and would do what people expect. We are explicitly circumventing an "unfortunate choice" in tuple comparisons. |
SIMD.jl does owns |
Given the rationale there – "This would provide custom showing of vectors with a specific new element type. While tempting, this should be avoided. The trouble is that users will expect a well-known type like Vector() to behave in a certain way, and overly customizing its behavior can make it harder to work with." – one could argue that overloading tuple comparisons is fine here because we're correcting an unexpected behaviour coming from an unfortunate choice made in Base. Of course, correcting this in Base would be better. |
Sure. Sometimes piracy is useful and needed (at least as a stopgap). I'm just pointing out that it is piracy. |
Yes, thank you. Indeed I did not realize that. |
I ran into the following issue while working with
NTuple
s ofVec
s:The tuples
(Vec(1, 2), Vec(3, 4))
and(Vec(5, 6), Vec(7, 8))
are absolutely not the same, but when compared with==
, Julia thinks they are! This comes from an unfortunate quirk of the wayBase._eq
is defined in tuple.jl, where any comparison result that is not explicitlyfalse
is treated astrue
.The text was updated successfully, but these errors were encountered: