[Scipy-svn] r5293 - in trunk/scipy/sparse: . tests

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Dec 27 16:53:03 EST 2008


Author: wnbell
Date: 2008-12-27 15:52:58 -0600 (Sat, 27 Dec 2008)
New Revision: 5293

Modified:
   trunk/scipy/sparse/construct.py
   trunk/scipy/sparse/tests/test_construct.py
Log:
fixed other bugs in sparse.eye


Modified: trunk/scipy/sparse/construct.py
===================================================================
--- trunk/scipy/sparse/construct.py	2008-12-27 21:44:20 UTC (rev 5292)
+++ trunk/scipy/sparse/construct.py	2008-12-27 21:52:58 UTC (rev 5293)
@@ -105,7 +105,7 @@
     is all ones and everything else is zeros.
     """
     m,n = int(m),int(n)
-    diags = np.ones((1, min(m + k, n)), dtype=dtype)
+    diags = np.ones((1, max(0, min(m + k, n))), dtype=dtype)
     return spdiags(diags, k, m, n).asformat(format)
 
 

Modified: trunk/scipy/sparse/tests/test_construct.py
===================================================================
--- trunk/scipy/sparse/tests/test_construct.py	2008-12-27 21:44:20 UTC (rev 5292)
+++ trunk/scipy/sparse/tests/test_construct.py	2008-12-27 21:52:58 UTC (rev 5293)
@@ -83,15 +83,10 @@
 
         assert_equal(eye(3,3,dtype='int16').dtype, 'int16')
 
-        assert_equal(eye(3, 4, -4).toarray(), np.eye(3, 4, -4))
-        assert_equal(eye(3, 4, -3).toarray(), np.eye(3, 4, -3))
-        assert_equal(eye(3, 4, -2).toarray(), np.eye(3, 4, -2))
-        assert_equal(eye(3, 4, -1).toarray(), np.eye(3, 4, -1))
-        assert_equal(eye(3, 4,  0).toarray(), np.eye(3, 4,  0))
-        assert_equal(eye(3, 4,  1).toarray(), np.eye(3, 4,  1))
-        assert_equal(eye(3, 4,  2).toarray(), np.eye(3, 4,  2))
-        assert_equal(eye(3, 4,  3).toarray(), np.eye(3, 4,  3))
-        assert_equal(eye(3, 4,  4).toarray(), np.eye(3, 4,  4))
+        for m in [3, 5]:
+            for n in [3, 5]:
+                for k in range(-5,6):
+                    assert_equal(eye(m, n, k=k).toarray(), np.eye(m, n, k=k))
 
     def test_kron(self):
         cases = []




More information about the Scipy-svn mailing list