|
From: Nico <nic...@li...> - 2006-02-10 20:24:27
|
Hi! a = array([0,1,0,0]) a[1:] |= a[:-1] gives the unexpected result [0 1 1 1] instead of [0 1 1 0] because python performs the |= on the forst cell, then on the second, and so on. I found two ways to get it right, with a copy: b = a.copy() a[1:] |= b[:-1] or working backward: a[-1:1:-1] |= a[-2:0:-1] which is better, in terms of speed (and memory management), for large 3D arrays? -- Nico |