[Numpy-discussion] a.T
Charles R Harris
charlesr.harris at gmail.com
Tue Dec 12 19:02:38 EST 2006
Hi all,
I'm curious about the error thrown when I use a.T as the left side of a
multiply assign. In the following, I am multiplying each the rows of 'a' by
the corresponding element of arange(n), i.e., broadcasting from the left.
The result looks fine, but an error is thrown after the operation is
complete.
In [62]: a = arange(12).reshape(3,2,2)
In [63]: a
Out[63]:
array([[[ 0, 1],
[ 2, 3]],
[[ 4, 5],
[ 6, 7]],
[[ 8, 9],
[10, 11]]])
In [64]: a.T *= arange(3)
---------------------------------------------------------------------------
exceptions.TypeError Traceback (most recent
call last)
/home/charris/workspace/microsat/tycho-work/<ipython console>
TypeError: attribute 'T' of 'numpy.ndarray' objects is not writable
In [65]: a
Out[65]:
array([[[ 0, 0],
[ 0, 0]],
[[ 4, 5],
[ 6, 7]],
[[16, 18],
[20, 22]]])
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20061212/4edfd930/attachment.html>
More information about the NumPy-Discussion
mailing list