diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2014-03-21 14:53:18 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2014-03-26 20:41:48 -0600 |
commit | 1eb81b7beaf571bdd534cfeec046b79b1d188714 (patch) | |
tree | d080fbd576b089e25619dce768b84ba3aeaf7db4 /numpy/polynomial/polynomial.py | |
parent | 46767a2ffc6bf7b3c6841bd9b10f1f26543d22b7 (diff) | |
download | numpy-1eb81b7beaf571bdd534cfeec046b79b1d188714.tar.gz |
ENH, MAINT: Use an abstract base class for the polynomial classes.
The new base is ABCPolyBase and is intended to replace the use of the
polytemplate string. In this way the need to compile the polynomial
classes on import is avoided.
Closes #634. Closes #3639.
Diffstat (limited to 'numpy/polynomial/polynomial.py')
-rw-r--r-- | numpy/polynomial/polynomial.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/numpy/polynomial/polynomial.py b/numpy/polynomial/polynomial.py index c30fc6d0c..f767a3067 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 @@ -1490,4 +1491,22 @@ def polyroots(c): # polynomial class # -exec(polytemplate.substitute(name='Polynomial', nick='poly', domain='[-1,1]')) +class Polynomial(ABCPolyBase): + # 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) |