diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2010-02-08 13:13:28 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2010-02-08 13:13:28 +0000 |
commit | 88c05e836e527f0780a6a1430f3dc459a215badf (patch) | |
tree | 5658b3e569d7a0e2d3618e930585b01cb5773c52 | |
parent | 69c2a3bff7c07fd88e35b02bf1cbfa5f48abd975 (diff) | |
download | numpy-88c05e836e527f0780a6a1430f3dc459a215badf.tar.gz |
BUG: Check input to poly for zero-dimensional arrays.
-rw-r--r-- | numpy/lib/polynomial.py | 4 | ||||
-rw-r--r-- | numpy/lib/tests/test_polynomial.py | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index e953f71ba..002b2859a 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -120,9 +120,9 @@ def poly(seq_of_zeros): """ seq_of_zeros = atleast_1d(seq_of_zeros) sh = seq_of_zeros.shape - if len(sh) == 2 and sh[0] == sh[1]: + if len(sh) == 2 and sh[0] == sh[1] and sh[0] != 0: seq_of_zeros = eigvals(seq_of_zeros) - elif len(sh) ==1: + elif len(sh) == 1: pass else: raise ValueError, "input must be 1d or square 2d array." diff --git a/numpy/lib/tests/test_polynomial.py b/numpy/lib/tests/test_polynomial.py index 85fc18933..bbc3b947e 100644 --- a/numpy/lib/tests/test_polynomial.py +++ b/numpy/lib/tests/test_polynomial.py @@ -143,5 +143,11 @@ class TestDocs(TestCase): p2 = p.integ(3, k=[9,7,6]) assert (p2.coeffs == [1/4./5.,1/3./4.,1/2./3.,9/1./2.,7,6]).all() + def test_zero_dims(self): + try: + np.poly(np.zeros((0, 0))) + except ValueError: + pass + if __name__ == "__main__": run_module_suite() |