From: Pete S. <pe...@sh...> - 2002-05-02 19:09:42
|
> def twod(n,m): > a = zeros((n,m,2)) > b = arange(n*m) > a[:,:,0] = transpose(reshape(b % n, (m,n))) > a[:,:,1] = reshape(b % m, (n,m)) > return a eric has sent me a great version off the list: def other_twod(n,m): q = indices((n, m) return transpose(q)[:,:,::-1] > It's not clear to me what you mean here. If you have an array with > shape (n,m,3) and want to get (n*m,3), just use reshape(a,(n*m,3)). > Maybe you mean something more complicated than that? no, this is exactly what i meant. in hindsight i realize i already knew how to do this. owell, and thanks for the answers :] |