[NumPy-Tickets] [NumPy] #1859: Broadcasting fails for A *= B
NumPy Trac
numpy-tickets@scipy....
Tue Jun 7 10:04:41 CDT 2011
#1859: Broadcasting fails for A *= B
--------------------+-------------------------------------------------------
Reporter: gerrit | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: Other | Version: devel
Keywords: |
--------------------+-------------------------------------------------------
The shape of the rhs in an operation A *= B is wrongly read, and thus the
operation fails. See code below.
{{{
$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from numpy import zeros
>>> A1 = zeros((2, 1, 1))
>>> A2 = zeros((2,))
>>> A1 * A2 # works
array([[[ 0., 0.]],
[[ 0., 0.]]])
>>> A1 *= A2 # fails
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: non-broadcastable output operand with shape (2,1,1) doesn't
match the broadcast shape (0,140018678770184,2)
>>> A1 *= A2 # fails
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: non-broadcastable output operand with shape (2,1,1) doesn't
match the broadcast shape (0,0,2)
>>> A1 *= A2 # fails
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: non-broadcastable output operand with shape (2,1,1) doesn't
match the broadcast shape (14885712,6881,2)
>>> from numpy.version import full_version, git_revision
>>> print full_version
2.0.0.dev-3071eab
>>> print git_revision
3071eab84b81ef6e0d157d46404c631547fed763
}}}
The same for +=, /=, etc.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1859>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list