ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> numpy-discussion
numpy-discussion
[Numpy-discussion] a.T
by Charles R Harris other posts by this author
Dec 12 2006 4:02PM messages near this date
Re: [Numpy-discussion] Histograms of extremely large data sets | Re: [Numpy-discussion] a.T
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
Thread:
Charles R Harris
Pierre GM

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved