You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2**63 is converted to a numpy uint64. The comparison int64 < uint64 is undefined, so it promotes to float64 < float64, and the precision is reduced, making them equal.
My guess is that numpy is just looking at the types on either side of the operator, and finding a common type to promote them to. Numpy could have been smarter, noticed that this was a comparison operator, and not done that, but, hey, none of us are smart all of the time.
Closing this one in favor of the related gh-12525. Keeping that open since comparisons are maybe a special case compared to the general promotion problem in gh-20905.
Activity
eric-wieser commentedon Aug 22, 2018
2**63is converted to a numpyuint64. The comparisonint64 < uint64is undefined, so it promotes tofloat64 < float64, and the precision is reduced, making them equal.eric-wieser commentedon Aug 22, 2018
Perhaps we ought to deprecate the promotion from integers to floats, and just switch to object arrays instead.
pitrou commentedon Aug 22, 2018
Comparison
int64withuint64sounds at least semantically well-defined to me.eric-wieser commentedon Aug 22, 2018
Sure, in this case I simply meant "we don't define it (yet)".
uint64 + int64is a similar case that is actually ill-definedpitrou commentedon Aug 22, 2018
Well, addition is ambiguous in case of overflow, but comparison is not ;-)
matthew-brett commentedon Aug 22, 2018
My guess is that numpy is just looking at the types on either side of the operator, and finding a common type to promote them to. Numpy could have been smarter, noticed that this was a comparison operator, and not done that, but, hey, none of us are smart all of the time.
eric-wieser commentedon Aug 23, 2018
Worse than that, the type of
uint + intis ambiguous in all cases.You're correct that comparison can be perfectly well-defined, but the C compiler won't define it for us sadly.
seberg commentedon May 12, 2022
Closing this one in favor of the related gh-12525. Keeping that open since comparisons are maybe a special case compared to the general promotion problem in gh-20905.