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
I would expect (a * b).sum() and np.dot(a, b) to be the same for 1D arrays. However, the former upscales(?) the dtype, and the latter doesn't, so they give different results. This may be expected behavior, but if so the np.dot docs should mention the dtype behavior.
Reproducing code example:
In [36]: a = np.array([254, 2, 200], dtype=np.uint8)
In [37]: b = np.array([True, False, True], dtype=np.bool)
In [38]: (a * b).sum()
Out[38]: 454
In [39]: np.dot(a, b)
Out[39]: 198
In [40]: np.dot(a, b).dtype
Out[40]: dtype('uint8')
Numpy/Python version information:
Numpy 1.15.0, Python 3.6.5
The text was updated successfully, but these errors were encountered:
The current design is to choose the output dtype with no consideration overflow. Overflow issues seem to frequently trip up users, perhaps an overall vision of how to deal with them is needed
I would expect
(a * b).sum()
andnp.dot(a, b)
to be the same for 1D arrays. However, the former upscales(?) the dtype, and the latter doesn't, so they give different results. This may be expected behavior, but if so thenp.dot
docs should mention the dtype behavior.Reproducing code example:
Numpy/Python version information:
Numpy 1.15.0, Python 3.6.5
The text was updated successfully, but these errors were encountered: