[Scipy-svn] r3109 - trunk/Lib/io

scipy-svn@scip... scipy-svn@scip...
Mon Jun 18 18:22:20 CDT 2007


Author: wnbell
Date: 2007-06-18 18:22:19 -0500 (Mon, 18 Jun 2007)
New Revision: 3109

Modified:
   trunk/Lib/io/mmio.py
Log:
added support for (sparse) "pattern" Matrix Market matrices 



Modified: trunk/Lib/io/mmio.py
===================================================================
--- trunk/Lib/io/mmio.py	2007-06-15 17:57:26 UTC (rev 3108)
+++ trunk/Lib/io/mmio.py	2007-06-18 23:22:19 UTC (rev 3109)
@@ -115,7 +115,7 @@
     elif field=='complex':
         dtype='D'
     elif field=='pattern':
-        raise NotImplementedError,`field`
+        dtype='d'
     else:
         raise ValueError,`field`
 
@@ -123,7 +123,8 @@
     is_complex = field=='complex'
     is_skew = symm=='skew-symmetric'
     is_herm = symm=='hermitian'
-
+    is_pattern = field=='pattern'
+    
     if rep == 'array':
         a = zeros((rows,cols),dtype=dtype)
         line = 1
@@ -193,7 +194,9 @@
                 l = line.split()
                 i = int(l[0])-1
                 j = int(l[1])-1
-                if is_complex:
+                if is_pattern:
+                    aij = 1.0 #use 1.0 for pattern matrices
+                elif is_complex:
                     aij = complex(*map(float,l[2:]))
                 else:
                     aij = float(l[2])



More information about the Scipy-svn mailing list