Hi all,
In NEP 50 (https://numpy.org/neps/nep-0050-scalar-promotion.html) my
current proposal is that the following:
np.array([1, 2], dtype="uint8") + (-1)
which currently returns an "int16" array must raise an error. This is
because we want to return a uint8 array but the -1 cannot be
represented well by -1.
The same should also happen for a value of 300 (rather than -1).
My main question is not about making this an error though. The
question is whether the following two cases should also error:
uint8_arr = np.array([1, 2], dtype="uint8")
uint8_arr[0] = -1
or:
np.array([-1], dtype=np.uint8)
(In practice these currently give the maximum integer with well defined
integer overflow.)
Note that the call `np.uint8(-1)` could be a special case here!
The reason I ask is that my PR:
https://github.com/numpy/numpy/pull/21875
currently introduces the new error without changing the other cases and
this requires adding a full new conversion path. If we want to change
that anyway (or keep things aligned), I could simplify the logic in the
PR.
Cheers,
Sebastian
_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: [email protected]