[Scipy-svn] r4785 - trunk/scipy/io

scipy-svn@scip... scipy-svn@scip...
Mon Oct 6 02:36:57 CDT 2008


Author: wnbell
Date: 2008-10-06 02:36:43 -0500 (Mon, 06 Oct 2008)
New Revision: 4785

Modified:
   trunk/scipy/io/mmio.py
Log:
writing of MatrixMarket now works for all integer kinds


Modified: trunk/scipy/io/mmio.py
===================================================================
--- trunk/scipy/io/mmio.py	2008-10-06 04:29:46 UTC (rev 4784)
+++ trunk/scipy/io/mmio.py	2008-10-06 07:36:43 UTC (rev 4785)
@@ -479,14 +479,15 @@
                 precision = 16
 
         if field is None:
-            if typecode in 'li':
+            kind = a.dtype.kind
+            if kind == 'i':
                 field = 'integer'
-            elif typecode in 'df':
+            elif kind == 'f':
                 field = 'real'
-            elif typecode in 'DF':
+            elif kind == 'c':
                 field = 'complex'
             else:
-                raise TypeError,'unexpected typecode '+typecode
+                raise TypeError('unexpected dtype kind ' + kind)
 
         if rep == self.FORMAT_ARRAY:
             symm = self._get_symmetry(a)
@@ -570,23 +571,6 @@
 
             savetxt(stream, IJV, fmt=fmt)
 
-
-            ### Old method
-            ## line template
-            #template = '%i %i ' + template
-            #I,J,V = coo.row + 1, coo.col + 1, coo.data # change base 0 -> base 1
-            #if field in (self.FIELD_REAL, self.FIELD_INTEGER):
-            #    for ijv_tuple in izip(I,J,V):
-            #        stream.writelines(template % ijv_tuple)
-            #elif field == self.FIELD_COMPLEX:
-            #    for ijv_tuple in izip(I,J,V.real,V.imag):
-            #        stream.writelines(template % ijv_tuple)
-            #elif field == self.FIELD_PATTERN:
-            #    raise NotImplementedError,`field`
-            #else:
-            #    raise TypeError,'Unknown field type %s'% `field`
-
-
 #-------------------------------------------------------------------------------
 if __name__ == '__main__':
     import sys



More information about the Scipy-svn mailing list