diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2008-03-15 18:27:45 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2008-03-15 18:27:45 +0000 |
commit | ebab42eef240821aa88db21ed0df3974cb350e22 (patch) | |
tree | 51d561a40e7f1a165d149d1b9be13500ae18b7a3 /numpy/lib/tests/test_polynomial.py | |
parent | dee3e75798731a79d4d4298bfe81d9a8dc07975f (diff) | |
download | numpy-ebab42eef240821aa88db21ed0df3974cb350e22.tar.gz |
Fix polyfit for 2D case and add test for same. Fixes ticket 697.
Diffstat (limited to 'numpy/lib/tests/test_polynomial.py')
-rw-r--r-- | numpy/lib/tests/test_polynomial.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_polynomial.py b/numpy/lib/tests/test_polynomial.py index 17d22e10e..012f49d77 100644 --- a/numpy/lib/tests/test_polynomial.py +++ b/numpy/lib/tests/test_polynomial.py @@ -94,5 +94,20 @@ class TestDocs(NumpyTestCase): p[1] = 0 assert_equal(str(p), " \n0") + def check_polyfit(self) : + c = np.array([3., 2., 1.]) + x = np.linspace(0,2,5) + y = np.polyval(c,x) + # check 1D case + assert_almost_equal(c, np.polyfit(x,y,2)) + # check 2D (n,1) case + y = y[:,np.newaxis] + c = c[:,np.newaxis] + assert_almost_equal(c, np.polyfit(x,y,2)) + # check 2D (n,2) case + yy = np.concatenate((y,y), axis=1) + cc = np.concatenate((c,c), axis=1) + assert_almost_equal(cc, np.polyfit(x,yy,2)) + if __name__ == "__main__": NumpyTest().run() |