[SciPy-user] TypeError: object has read-only attributes

Colin J. Williams cjw at sympatico.ca
Fri Jul 25 14:15:39 EDT 2003


Nils Wagner wrote:

>Hi all,
>
>I would like to change an entry of a complex array.
>
>  
>
>>>>t
>>>>        
>>>>
>array([ 0.30993965+0.21102825j,  0.40232318+0.48098591j,
>             0.30927754+0.3310895j ,  0.36197345+0.36041015j])
>  
>
>>>>t[0]
>>>>        
>>>>
>(0.30993964566340926+0.21102825078044135j)
>  
>
>>>>t[0].real
>>>>        
>>>>
>0.30993964566340926
>  
>
>>>>t[0].real=0
>>>>        
>>>>
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>TypeError: object has read-only attributes
>
>  
>
>>>>t[0]=1
>>>>t[0]
>>>>        
>>>>
>(1+0j)
>  
>
>
>What's the trouble ?
>
>Nils
>
>_______________________________________________
>SciPy-user mailing list
>SciPy-user at scipy.net
>http://www.scipy.net/mailman/listinfo/scipy-user
>
>  
>
Nils,

You probably need something like:

a= t[0].imag
t[0]= complex(0, a)

Colin W.




More information about the SciPy-User mailing list