Closed
Description
This doesn't look at all desirable to me:
>>> lbnd = np.int64(np.iinfo(np.int64).max); lbnd
9223372036854775807
>>> ubnd = np.uint64(np.iinfo(np.int64).max + 1)
9223372036854775808
>>> lbnd == ubnd
True
>>> np.equal(lbnd, ubnd, casting='safe')
True
>>> np.equal(lbnd, ubnd, casting='samekind')
True
>>> int(lbnd) == int(ubnd) # well, one of these behaves as expected...
False
Frankly, this is PHP-like behaviour, and not something I want to see happening quietly in python
Clearly what's happening here is that np.equal
is upcasting both arguments to float, since combining a uint64
and int64
requires a int128
for storage.
I don't think relational operators should be allowed to make this conversion, and should either error, or do more work to determine the correct result.
Perhaps in general, we should warn when a (uint64,int64)->float
conversion occurs, and ask that it be written explicitly? At the very least, I don't think this operation is appropriately covered by casting="safe"