|
5 | 5 | from fractions import Fraction
|
6 | 6 | import numpy as np
|
7 | 7 | import numpy.polynomial.polynomial as poly
|
| 8 | +import numpy.polynomial.polyutils as pu |
8 | 9 | import pickle
|
9 | 10 | from copy import deepcopy
|
10 | 11 | from numpy.testing import (
|
11 | 12 | assert_almost_equal, assert_raises, assert_equal, assert_,
|
12 |
| - assert_array_equal, assert_raises_regex) |
| 13 | + assert_array_equal, assert_raises_regex, assert_warns) |
13 | 14 |
|
14 | 15 |
|
15 | 16 | def trim(x):
|
@@ -628,6 +629,14 @@ def test_polyline(self):
|
628 | 629 | def test_polyline_zero(self):
|
629 | 630 | assert_equal(poly.polyline(3, 0), [3])
|
630 | 631 |
|
| 632 | + def test_fit_degenerate_domain(self): |
| 633 | + p = poly.Polynomial.fit([1], [2], deg=0) |
| 634 | + assert_equal(p.coef, [2.]) |
| 635 | + p = poly.Polynomial.fit([1, 1], [2, 2.1], deg=0) |
| 636 | + assert_almost_equal(p.coef, [2.05]) |
| 637 | + with assert_warns(pu.RankWarning): |
| 638 | + p = poly.Polynomial.fit([1, 1], [2, 2.1], deg=1) |
| 639 | + |
631 | 640 | def test_result_type(self):
|
632 | 641 | w = np.array([-1, 1], dtype=np.float32)
|
633 | 642 | p = np.polynomial.Polynomial(w, domain=w, window=w)
|
|
0 commit comments