[Scipy-svn] r3777 - trunk/scipy/io/matlab

scipy-svn@scip... scipy-svn@scip...
Thu Jan 3 18:20:45 CST 2008


Author: stefan
Date: 2008-01-03 18:20:17 -0600 (Thu, 03 Jan 2008)
New Revision: 3777

Modified:
   trunk/scipy/io/matlab/mio5.py
Log:
Fix array name writing in MATLAB v5 format.


Modified: trunk/scipy/io/matlab/mio5.py
===================================================================
--- trunk/scipy/io/matlab/mio5.py	2008-01-03 22:16:43 UTC (rev 3776)
+++ trunk/scipy/io/matlab/mio5.py	2008-01-04 00:20:17 UTC (rev 3777)
@@ -604,10 +604,13 @@
         self.write_dtype(af)
         # write array shape
         if self.arr.ndim < 2:
-            self.arr=N.atleast_2d(self.arr)
+            new_arr = N.atleast_2d(self.arr)
+            if type(new_arr) != type(self.arr):
+                raise ValueError("Array should be 2-dimensional.")
+            self.arr = new_arr
         self.write_element(N.array(self.arr.shape, dtype='i4'))
         # write name
-        self.write_element(N.ndarray(shape=len(self.name), dtype='S1', buffer=self.name))
+        self.write_element(N.array([ord(c) for c in self.name], 'i1'))
 
     def update_matrix_tag(self):
         curr_pos = self.file_stream.tell()



More information about the Scipy-svn mailing list