[Numpy-discussion] Assigning an array to the field of a structure doesn't work

Jeremy Lewi jlewi@intellisis....
Thu Sep 24 19:42:32 CDT 2009


Hi

   I'm trying to understand the following code:

 

    import numpy as np

 

    dt=np.dtype([("c",np.int32,(2))])

    

    data=np.ndarray([2],dtype=dt)

    

    x=np.array([0,10])

 

    #the following line doesn't set data[0]["c"] = x

    #only data[0]["c"][0] changes    

    data[0]["c"]=x

    

    #the following does set data[1]["c"][:]=x

    data[1]["c"][:]=x

    

 

What I don't understand is why does, the assignment of data[0]["c"]=x not
set c=x but the second one does?

 

Thanks

Jeremy            

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090924/484d8573/attachment-0001.html 


More information about the NumPy-Discussion mailing list