diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-06-20 16:49:49 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-06-20 17:31:35 -0600 |
commit | 12e06a261e8ea6b08002de8e9933fd43e5465df9 (patch) | |
tree | 527a2df97d58a190de018b4a917f3be06908f541 /numpy/polynomial/tests/test_chebyshev.py | |
parent | b3755926f5e5dc9fde273a8bf53bd98238e8e2b8 (diff) | |
download | numpy-12e06a261e8ea6b08002de8e9933fd43e5465df9.tar.gz |
BUG: Campanion Matrix was scalar, not matrix for degree 1.
The companion matrices returned by the various polynomial types was
a scalar in the degree one case instead of a 2-D array. Fix that and
add a test to check for that result.
Closes #3459.
Diffstat (limited to 'numpy/polynomial/tests/test_chebyshev.py')
-rw-r--r-- | numpy/polynomial/tests/test_chebyshev.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/numpy/polynomial/tests/test_chebyshev.py b/numpy/polynomial/tests/test_chebyshev.py index 23a17b464..367d81f58 100644 --- a/numpy/polynomial/tests/test_chebyshev.py +++ b/numpy/polynomial/tests/test_chebyshev.py @@ -440,6 +440,22 @@ class TestFitting(TestCase): x = [1, 1j, -1, -1j] assert_almost_equal(cheb.chebfit(x, x, 1), [0, 1]) + +class TestCompanion(TestCase): + + def test_raises(self): + assert_raises(ValueError, cheb.chebcompanion, []) + assert_raises(ValueError, cheb.chebcompanion, [1]) + + def test_dimensions(self): + for i in range(1, 5): + coef = [0]*i + [1] + assert_(cheb.chebcompanion(coef).shape == (i, i)) + + def test_linear_root(self): + assert_(cheb.chebcompanion([1, 2])[0, 0] == -.5) + + class TestGauss(TestCase): def test_100(self): |