[SciPy-user] Polynomial interpolation
Sun Apr 20 20:21:58 CDT 2008
On 19/04/2008, Gabriel Gellner <email@example.com> wrote:
> I really like the OO design. If you continue down this route would you make the
> class new style (inherit from object), and why not use properties for the
> set_yi, would make it all the sweeter.
Hmm. I'm lukewarm on using properties. It seems to me that if I
provide set_foo functions people will assume that it's not safe to
modify any attribute directly; if I override __setattr__ so that the
right magic happens, that implicitly encourages people to change any
attribute that doesn't raise an exception. Which means that I need to
evaluate whether each attribute can be safely modified on the fly, and
access those that can't through object.__setattr__(self,"name",value).
I also need to explicitly document which attributes may be safely
written to. Is this about right? Is this the new python standard
More generally, it seems to me that generically, interpolation schemes
should produce objects which can be evaluated like functions. They
should perhaps have certain other standard features: providing
derivatives, if they can, through one of a few standardly-named
functions, providing acceptable input ranges (or recommended input
ranges) in standardly-named attributes, ... anything else?
What about other "function" objects in numpy/scipy that know their
derivatives (or integrals), should they provide extra functions to
It seems like "knowing your derivatives" comes in at least three
forms: being able to compute the value of a particular derivative on
demand (e.g. splev(x,tck,der=2)), being able to evaluate all (or some)
derivatives on demand (e.g. KroghInterpolator(xi,yi).derivatives(x)),
and being able to construct a full-fledged function object
representing the derivative (e.g. poly1d([2,1,0]).deriv()). Certainly
one can use any of these to fudge the others, but it involves varying
degrees of clumsiness and inefficiency.
I'm just thinking about how to make duck typing as useful as possible
for interpolator objects.
More information about the SciPy-user