[Numpy-discussion] Structure of polynomial module
Charles R Harris
Mon Feb 6 16:34:59 CST 2012
2012/2/6 Stéfan van der Walt <email@example.com>
> Hi all,
> I noticed the following docstring on ``np.polynomial.polyval``:
> In : np.polynomial.polyval?
> File: /home/stefan/src/numpy/numpy/lib/utils.py
> Definition: np.polynomial.polyval(*args, **kwds)
> `polyval` is deprecated!
> Please import polyval from numpy.polynomial.polynomial
> I guess we don't expect users to do "from numpy.polynomial.polynomial
> import polyval, Polynomial", so what is the suggested API for getting
> hold of the polynomial functions?
You can still import Polynomial from numpy.polynomial. The other functions
were removed because 1) They are essentially duplicated for 6 polynomial
types, 2) they are mostly there to support Polynomial. You shouldn't need
them for most things if you use Polynomial.
> Also, why is
> numpy.polynomial.polynomial.polyfit different from numpy.polyfit?
Use Polynomial.fit, it tracks the domain for you. Want to use Legendre
functions? Use Legendre.fit. Want to plot the result? plot(*p.linspace()),
want to plot the derivative? plot(*p.deriv().linspace()). Want to convert a
Legendre series to a Polynomial? p.convert(kind=Polynomial). So on and so
forth. The fitting is also NA aware in the development branch.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion