diff options
Diffstat (limited to 'numpy/polynomial/polynomial.py')
-rw-r--r-- | numpy/polynomial/polynomial.py | 70 |
1 files changed, 57 insertions, 13 deletions
diff --git a/numpy/polynomial/polynomial.py b/numpy/polynomial/polynomial.py index c30fc6d0c..97f4fd148 100644 --- a/numpy/polynomial/polynomial.py +++ b/numpy/polynomial/polynomial.py @@ -61,11 +61,12 @@ __all__ = ['polyzero', 'polyone', 'polyx', 'polydomain', 'polyline', 'polyfit', 'polytrim', 'polyroots', 'Polynomial', 'polyval2d', 'polyval3d', 'polygrid2d', 'polygrid3d', 'polyvander2d', 'polyvander3d'] +import warnings import numpy as np import numpy.linalg as la + from . import polyutils as pu -import warnings -from .polytemplate import polytemplate +from ._polybase import ABCPolyBase polytrim = pu.trimcoef @@ -823,7 +824,7 @@ def polyval2d(x, y, c): Notes ----- - .. versionadded::1.7.0 + .. versionadded:: 1.7.0 """ try: @@ -883,7 +884,7 @@ def polygrid2d(x, y, c): Notes ----- - .. versionadded::1.7.0 + .. versionadded:: 1.7.0 """ c = polyval(x, c) @@ -936,7 +937,7 @@ def polyval3d(x, y, z, c): Notes ----- - .. versionadded::1.7.0 + .. versionadded:: 1.7.0 """ try: @@ -1000,7 +1001,7 @@ def polygrid3d(x, y, z, c): Notes ----- - .. versionadded::1.7.0 + .. versionadded:: 1.7.0 """ c = polyval(x, c) @@ -1173,7 +1174,7 @@ def polyvander3d(x, y, z, deg) : Notes ----- - .. versionadded::1.7.0 + .. versionadded:: 1.7.0 """ ideg = [int(d) for d in deg] @@ -1249,12 +1250,16 @@ def polyfit(x, y, deg, rcond=None, full=False, w=None): the coefficients in column `k` of `coef` represent the polynomial fit to the data in `y`'s `k`-th column. - [residuals, rank, singular_values, rcond] : present when `full` == True - Sum of the squared residuals (SSR) of the least-squares fit; the - effective rank of the scaled Vandermonde matrix; its singular - values; and the specified value of `rcond`. For more information, - see `linalg.lstsq`. + [residuals, rank, singular_values, rcond] : list + These values are only returned if `full` = True + resid -- sum of squared residuals of the least squares fit + rank -- the numerical rank of the scaled Vandermonde matrix + sv -- singular values of the scaled Vandermonde matrix + rcond -- value of `rcond`. + + For more details, see `linalg.lstsq`. + Raises ------ RankWarning @@ -1490,4 +1495,43 @@ def polyroots(c): # polynomial class # -exec(polytemplate.substitute(name='Polynomial', nick='poly', domain='[-1,1]')) +class Polynomial(ABCPolyBase): + """A power series class. + + The Polynomial class provides the standard Python numerical methods + '+', '-', '*', '//', '%', 'divmod', '**', and '()' as well as the + attributes and methods listed in the `ABCPolyBase` documentation. + + Parameters + ---------- + coef : array_like + Polynomial coefficients in order of increasing degree, i.e., + ``(1, 2, 3)`` give ``1 + 2*x + 3*x**2``. + domain : (2,) array_like, optional + Domain to use. The interval ``[domain[0], domain[1]]`` is mapped + to the interval ``[window[0], window[1]]`` by shifting and scaling. + The default value is [-1, 1]. + window : (2,) array_like, optional + Window, see `domain` for its use. The default value is [-1, 1]. + + .. versionadded:: 1.6.0 + + """ + # Virtual Functions + _add = staticmethod(polyadd) + _sub = staticmethod(polysub) + _mul = staticmethod(polymul) + _div = staticmethod(polydiv) + _pow = staticmethod(polypow) + _val = staticmethod(polyval) + _int = staticmethod(polyint) + _der = staticmethod(polyder) + _fit = staticmethod(polyfit) + _line = staticmethod(polyline) + _roots = staticmethod(polyroots) + _fromroots = staticmethod(polyfromroots) + + # Virtual properties + nickname = 'poly' + domain = np.array(polydomain) + window = np.array(polydomain) |