-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Closed
Labels
62 - Python APIChanges or additions to the Python API. Mailing list should usually be notified.Changes or additions to the Python API. Mailing list should usually be notified.
Description
NumPy operations generally follow the rule that the output dtype/shape is a deterministic function of the inputs dtype/shape.
However, binary arithmetic with 0d arrays appears to be an exception to these rules. Consider:
np.array(12).dtype # int64
np.array(4625196817309499392).dtype # int64
(np.array([[123]], dtype=np.float32) + np.array(12)).dtype # float32
(np.array([[123]], dtype=np.float32) + np.array(4625196817309499392)).dtype # float64
Basically, whether the result is float32 depends on the size of the scalar argument.
I can see why this would be desirable for operations with Python scalars (e.g., array + 1
), but when the 0d/scalar argument is already typed this is highly surprising.
EDIT seberg: This is basically what NEP 50 is about.
Metadata
Metadata
Assignees
Labels
62 - Python APIChanges or additions to the Python API. Mailing list should usually be notified.Changes or additions to the Python API. Mailing list should usually be notified.