[Numpy-discussion] abs for max negative integers - desired behavior?
Matthew Brett
matthew.brett at gmail.com
Tue Oct 11 14:23:15 EDT 2011
Hi,
I recently ran into this:
In [68]: arr = np.array(-128, np.int8)
In [69]: arr
Out[69]: array(-128, dtype=int8)
In [70]: np.abs(arr)
Out[70]: -128
Of course, I can see why this happens, but it is still surprising, and
it seems to me that it would be a confusing source of bugs, because of
course it only happens for the maximum negative integer.
One particular confusing result was:
In [71]: np.allclose(arr, arr)
Out[71]: False
I wanted to ask whether this is the desired behavior, and whether it
might be worth planning a change in the long term?
Best,
Matthew
More information about the NumPy-Discussion
mailing list