[Tutor] calculation with arrays: shape mismatch

John washakie at gmail.com
Mon Oct 29 16:22:29 CET 2007


Does anyone have an idea why I can't do this?

 for k in range(nr):
  contribution=N.zeros(shape(H['area']))
  contribution=[contribution+grid[:,:,z:,k,0]/A for z in
range(len(H['outheight']))]
  zplot[:,:,k]=zplot[:,:,k]+contribution;


And on the interactive line:
>>> shape(contribution)
(360, 180)
>>> shape(grid[:,:,0,0,0])
(360, 180)
>>>


But I get the error:
ValueError: shape mismatch: objects cannot be broadcast to a single shape

 for the highlighted line.

Thanks!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071029/3bcffc76/attachment-0001.htm 


More information about the Tutor mailing list