-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Closed
Description
xref #2357
In [1]: import numpy as np
In [2]: np.__version__
Out[2]: '1.9.1'
In [3]: arr = np.zeros([5, 2])
In [4]: arr[:,[0,1]] = np.arange(10).reshape([2, 5])
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-fe63af63442b> in <module>()
----> 1 arr[:,[0,1]] = np.arange(10).reshape([2, 5])
ValueError: shape mismatch: value array of shape (2,5) could not be broadcast to
indexing result of shape (2,5) # BAD
In [5]: arr[:,[0,1]] + np.arange(10).reshape([2, 5])
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-5-8c656689a6ee> in <module>()
----> 1 arr[:,[0,1]] + np.arange(10).reshape([2, 5])
ValueError: operands could not be broadcast together with shapes (5,2) (2,5) # correctThe first error message is confusing at best.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels