[Numpy-discussion] numpy-izing a loop

Stéfan van der Walt stefan@sun.ac...
Tue Feb 10 15:33:35 CST 2009


2009/2/10 Stéfan van der Walt <stefan@sun.ac.za>:
> x = np.arange(dim)
> y = np.arange(dim)[:, None]
> z = np.arange(dim)[:, None, None]

Do not operate heavy machinery or attempt broadcasting while tired or
under the influence.  That order was incorrect:

> z = np.arange(dim)
> y = np.arange(dim)[:, None]
> x = np.arange(dim)[:, None, None]

Cheers
Stéfan


More information about the Numpy-discussion mailing list