summaryrefslogtreecommitdiff
path: root/numpy/polynomial/tests/test_polynomial.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-06-20 16:49:49 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-06-20 17:31:35 -0600
commit12e06a261e8ea6b08002de8e9933fd43e5465df9 (patch)
tree527a2df97d58a190de018b4a917f3be06908f541 /numpy/polynomial/tests/test_polynomial.py
parentb3755926f5e5dc9fde273a8bf53bd98238e8e2b8 (diff)
downloadnumpy-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_polynomial.py')
-rw-r--r--numpy/polynomial/tests/test_polynomial.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/numpy/polynomial/tests/test_polynomial.py b/numpy/polynomial/tests/test_polynomial.py
index 3d9519679..583872978 100644
--- a/numpy/polynomial/tests/test_polynomial.py
+++ b/numpy/polynomial/tests/test_polynomial.py
@@ -383,6 +383,21 @@ class TestVander(TestCase):
assert_(van.shape == (1, 5, 24))
+class TestCompanion(TestCase):
+
+ def test_raises(self):
+ assert_raises(ValueError, poly.polycompanion, [])
+ assert_raises(ValueError, poly.polycompanion, [1])
+
+ def test_dimensions(self):
+ for i in range(1, 5):
+ coef = [0]*i + [1]
+ assert_(poly.polycompanion(coef).shape == (i, i))
+
+ def test_linear_root(self):
+ assert_(poly.polycompanion([1, 2])[0, 0] == -.5)
+
+
class TestMisc(TestCase) :
def test_polyfromroots(self) :