[Numpy-discussion] numpy-izing a loop
Stéfan van der Walt
stefan@sun.ac...
Tue Feb 10 15:27:31 CST 2009
2009/2/10 Robert Kern <robert.kern@gmail.com>:
> x = np.arange(dim)[:,np.newaxis,np.newaxis]
> y = np.arange(dim)[np.newaxis,:,np.newaxis]
> z = np.arange(dim)[np.newaxis,np.newaxis,:]
Yes, sorry, I should have copied from my terminal.
I think I had
x = np.arange(dim)
y = np.arange(dim)[:, None]
z = np.arange(dim)[:, None, None]
which broadcasts the same way.
Cheers
Stéfan
More information about the Numpy-discussion
mailing list