
Dec. 4, 2010
7 p.m.
Hi guys, I would like to know if there is any way to make the following operation faster. def test(): shape=(200,200,200,3) refinds = np.ndindex(shape[:3]) reftmp=np.zeros(shape) for ijk_t in refinds: i,j,k = ijk_t reftmp[i,j,k,0]=i reftmp[i,j,k,1]=j reftmp[i,j,k,2]=k %timeit test() 1 loops, best of 3: 19.5 s per loop I am using ndindex and then a for loop. Is there a better/faster way? Thank you, Eleftherios