[Numpy-svn] r8096 - in trunk/numpy/lib: . tests

numpy-svn@scip... numpy-svn@scip...
Mon Feb 8 07:13:28 CST 2010


Author: stefan
Date: 2010-02-08 07:13:28 -0600 (Mon, 08 Feb 2010)
New Revision: 8096

Modified:
   trunk/numpy/lib/polynomial.py
   trunk/numpy/lib/tests/test_polynomial.py
Log:
BUG: Check input to poly for zero-dimensional arrays.

Modified: trunk/numpy/lib/polynomial.py
===================================================================
--- trunk/numpy/lib/polynomial.py	2010-02-08 07:35:34 UTC (rev 8095)
+++ trunk/numpy/lib/polynomial.py	2010-02-08 13:13:28 UTC (rev 8096)
@@ -120,9 +120,9 @@
     """
     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."

Modified: trunk/numpy/lib/tests/test_polynomial.py
===================================================================
--- trunk/numpy/lib/tests/test_polynomial.py	2010-02-08 07:35:34 UTC (rev 8095)
+++ trunk/numpy/lib/tests/test_polynomial.py	2010-02-08 13:13:28 UTC (rev 8096)
@@ -143,5 +143,11 @@
         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()



More information about the Numpy-svn mailing list