[Numpy-discussion] New patch for new mgrid / ogrid functionality

Gael Varoquaux gael.varoquaux at normalesup.org
Mon Sep 22 04:53:29 EDT 2008


On Mon, Sep 22, 2008 at 09:40:42AM +0200, Stéfan van der Walt wrote:
> 2008/9/19 David M. Kaplan <David.Kaplan at ird.fr>:
> > My 2 cents - I personally think the version that always returns a list
> > will ultimately be more transparent and cause fewer problems than the
> > newer version.  In either case, the plan should be to eventually have it
> > always return a list as that is the only fully consistent option, the
> > question is just when that switch should be made and by who.  If it is
> > done at the next major release, someone else will have to remember to ax
> > the additional code and correct the documentation....

> I think this change is worth making, because:

> - It provides a consistent API for gridding.
> - It optimises the most frequenty used situation:

> x, y, z = ogrid[...]

> - Someone already took the trouble of writing the patch.

> If the (minor) API breakage is considered a problem, could we go
> through the standard deprecation process and have this included?

I must admit I don't really like the API breakage. People will find out
that some code that used to work doesn't work anymore. 

In addition there is some real usecase behind the mgrid behavior:


X = mgrid[0:4, 0:4, 0:4]
X = X.reshape((3, -1))

scatter(X[0, :], X[1, :])

R = matrix(((cos(0.5), sin(0.5), 0), (-sin(0.5), cos(0.5), 0), (0, 0, 1)))

Y = array(R*X)

scatter(Y[0, :], Y[1, :], color='r')

Gaël



More information about the NumPy-Discussion mailing list