summaryrefslogtreecommitdiff
path: root/numpy/polynomial
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/polynomial')
-rw-r--r--numpy/polynomial/polytemplate.py4
-rw-r--r--numpy/polynomial/tests/test_polynomial.py3
2 files changed, 7 insertions, 0 deletions
diff --git a/numpy/polynomial/polytemplate.py b/numpy/polynomial/polytemplate.py
index 8314cecf9..424ce7f48 100644
--- a/numpy/polynomial/polytemplate.py
+++ b/numpy/polynomial/polytemplate.py
@@ -303,6 +303,10 @@ class $name(pu.PolyBase) :
# Extra numeric functions.
#
+ def degree(self) :
+ """The degree of the series."""
+ return len(self) - 1
+
def convert(self, domain=None, kind=None) :
"""Convert to different class and/or domain.
diff --git a/numpy/polynomial/tests/test_polynomial.py b/numpy/polynomial/tests/test_polynomial.py
index 81286d01b..34a3d10f3 100644
--- a/numpy/polynomial/tests/test_polynomial.py
+++ b/numpy/polynomial/tests/test_polynomial.py
@@ -370,6 +370,9 @@ class TestPolynomialClass(TestCase) :
xx = 2*x - 1
assert_almost_equal(self.p2(x), self.p1(xx))
+ def test_degree(self) :
+ assert_equal(self.p1.degree(), 2)
+
def test_convert(self) :
x = np.linspace(-1,1)
p = self.p1.convert(domain=[0,1])