From 1eb81b7beaf571bdd534cfeec046b79b1d188714 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 21 Mar 2014 14:53:18 -0600 Subject: 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. --- numpy/polynomial/hermite.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'numpy/polynomial/hermite.py') diff --git a/numpy/polynomial/hermite.py b/numpy/polynomial/hermite.py index 4140acfb7..ba96b98b7 100644 --- a/numpy/polynomial/hermite.py +++ b/numpy/polynomial/hermite.py @@ -59,11 +59,12 @@ See also """ from __future__ import division, absolute_import, print_function +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 __all__ = ['hermzero', 'hermone', 'hermx', 'hermdomain', 'hermline', 'hermadd', 'hermsub', 'hermmulx', 'hermmul', 'hermdiv', 'hermpow', @@ -1747,4 +1748,22 @@ def hermweight(x): # Hermite series class # -exec(polytemplate.substitute(name='Hermite', nick='herm', domain='[-1,1]')) +class Hermite(ABCPolyBase): + # Virtual Functions + _add = staticmethod(hermadd) + _sub = staticmethod(hermsub) + _mul = staticmethod(hermmul) + _div = staticmethod(hermdiv) + _pow = staticmethod(hermpow) + _val = staticmethod(hermval) + _int = staticmethod(hermint) + _der = staticmethod(hermder) + _fit = staticmethod(hermfit) + _line = staticmethod(hermline) + _roots = staticmethod(hermroots) + _fromroots = staticmethod(hermfromroots) + + # Virtual properties + nickname = 'herm' + domain = np.array(hermdomain) + window = np.array(hermdomain) -- cgit v1.2.1 From a2c96a6ad79efe81520e18078a6dee61c78113ef Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 21 Mar 2014 18:22:45 -0600 Subject: DOC: Fixup documentation for new way of generating classes. Move the class documentation to the place of definition in the appropriate module. This allow for documenting the specific series kind along with the series specific default domains and windows Remove template placeholders from the ABCPolyBase class documention. General fixup of documentation that rendered poorly. --- numpy/polynomial/hermite.py | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'numpy/polynomial/hermite.py') diff --git a/numpy/polynomial/hermite.py b/numpy/polynomial/hermite.py index ba96b98b7..7d2aa38a2 100644 --- a/numpy/polynomial/hermite.py +++ b/numpy/polynomial/hermite.py @@ -1417,10 +1417,15 @@ def hermfit(x, y, deg, rcond=None, full=False, w=None): the coefficients for the data in column k of `y` are in column `k`. - [residuals, rank, singular_values, rcond] : present when `full` = True - Residuals of the least-squares fit, the effective rank of the - scaled Vandermonde matrix and its singular values, and the - specified value of `rcond`. For more details, 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`. Warns ----- @@ -1749,6 +1754,27 @@ def hermweight(x): # class Hermite(ABCPolyBase): + """An Hermite series class. + + The Hermite 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 + Laguerre coefficients in order of increasing degree, i.e, + ``(1, 2, 3)`` gives ``1*H_0(x) + 2*H_1(X) + 3*H_2(x)``. + 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(hermadd) _sub = staticmethod(hermsub) -- cgit v1.2.1