[Scipy-svn] r5579 - in trunk/scipy/io/matlab: . tests

scipy-svn@scip... scipy-svn@scip...
Thu Feb 19 22:10:49 CST 2009


Author: matthew.brett@gmail.com
Date: 2009-02-19 22:10:47 -0600 (Thu, 19 Feb 2009)
New Revision: 5579

Modified:
   trunk/scipy/io/matlab/mio4.py
   trunk/scipy/io/matlab/tests/test_mio.py
Log:
On second thoughts, return matlab 4 behavior to 1d->row, for compatibility

Modified: trunk/scipy/io/matlab/mio4.py
===================================================================
--- trunk/scipy/io/matlab/mio4.py	2009-02-20 04:01:10 UTC (rev 5578)
+++ trunk/scipy/io/matlab/mio4.py	2009-02-20 04:10:47 UTC (rev 5579)
@@ -320,7 +320,7 @@
         self.write_bytes(ijv)
 
 
-def matrix_writer_factory(stream, arr, name, oned_as):
+def matrix_writer_factory(stream, arr, name, oned_as='row'):
     ''' Factory function to return matrix writer given variable to write
     stream      - file or file-like stream to write to
     arr         - array to write
@@ -344,12 +344,8 @@
     ''' Class for writing matlab 4 format files '''
     def __init__(self, file_stream, oned_as=None):
         self.file_stream = file_stream
-        # deal with deprecations
         if oned_as is None:
-            warnings.warn("Using oned_as default value ('column')" +
-                          " This will change to 'row' in future versions",
-                          FutureWarning, stacklevel=2)
-            oned_as = 'column'
+            oned_as = 'row'
         self.oned_as = oned_as
 
     def put_variables(self, mdict):

Modified: trunk/scipy/io/matlab/tests/test_mio.py
===================================================================
--- trunk/scipy/io/matlab/tests/test_mio.py	2009-02-20 04:01:10 UTC (rev 5578)
+++ trunk/scipy/io/matlab/tests/test_mio.py	2009-02-20 04:10:47 UTC (rev 5579)
@@ -470,15 +470,21 @@
 
 
 def test_1d_shape():
+    # Current 5 behavior is 1D -> column vector
+    arr = np.arange(5)
+    stream = StringIO()
+    savemat(stream, {'oned':arr}, format='5')
+    vals = loadmat(stream)
+    yield assert_equal, vals['oned'].shape, (5,1)
+    # Current 4 behavior is 1D -> row vector
+    arr = np.arange(5)
+    stream = StringIO()
+    savemat(stream, {'oned':arr}, format='4')
+    vals = loadmat(stream)
+    yield assert_equal, vals['oned'].shape, (1, 5)
     for format in ('4', '5'):
-        # Current behavior is 1D -> column vector
-        arr = np.arange(5)
+        # can be explicitly 'column' for oned_as
         stream = StringIO()
-        savemat(stream, {'oned':arr}, format=format)
-        vals = loadmat(stream)
-        yield assert_equal, vals['oned'].shape, (5,1)
-        # which is the same as 'column' for oned_as
-        stream = StringIO()
         savemat(stream, {'oned':arr}, 
                 format=format,
                 oned_as='column')



More information about the Scipy-svn mailing list