[SciPy-Dev] interp2d bounds checking

Pauli Virtanen pav at iki.fi
Sun Jul 1 14:40:16 EDT 2012


01.07.2012 11:21, Ralf Gommers kirjoitti:
[clip]
> Bounds checking on a 2-D grid isn't really more difficult than on a 1-D
> grid. It looks like someone just copied the interp1d interface and then
> ran out of time or energy to fully implement it.
> 
> Would be good if someone feels like implementing the missing bits, and
> otherwise we should at least document that right now out-of-bounds input
> simply raises an error (I didn't check which one).

IMO, interp2d should be deprecated.

It is equivalent to SmoothBivariateSpline with s=0.

It's sort of a almost-name-alias for a Matlab function, but it works
differently --- scattered data interpolation vs. grid interpolation.
However, as FITPACK's 2-D scattered data splines not so rarely explode
with real data, I don't think this "replacement function" does its work
properly, so it should be deprecated. If the users want these 2-D
splines, it's better to make them ask for them explicitly...

We can maybe think about adding a deprecation category "deprecated and
removed from documentation, but we'll keep it around indefinitely for
backwards compatibility". Move to e.g. to a new file '_deprecated.py' to
keep the moldy code separate.

   ***

What's needed is a proper grid-base interpolation. It would be rather
easy to write a simple wrapper around ndimage.map_coordinates to get
general spline interpolation. Such interpolants are also easy to
construct up from the polynomial interpolants in Scipy.

If someone is looking for something to do: *here* would be a nice, a
relatively easy, and very likely a very useful project to work on.

    ***

Also, where interp2d works, griddata should work better in most use cases.

I've also been thinking about enlarging the griddata syntax from the
possibly somewhat unfriendly

	griddata((x, y), z, (xi, yi), **kw)
	griddata((x, y, z), u, (xi, yi, zi), **kw)

to the variable argument one

	griddata(x, y, z, xi, yi, **kw)
	griddata(x, y, z, u, xi, yi, zi, **kw)

which may be more familiar to users. Thoughts?

	Pauli




More information about the SciPy-Dev mailing list