[Scipy-svn] r5247 - trunk/scipy/io/matlab/tests

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Dec 13 21:59:48 EST 2008


Author: matthew.brett at gmail.com
Date: 2008-12-13 20:59:20 -0600 (Sat, 13 Dec 2008)
New Revision: 5247

Modified:
   trunk/scipy/io/matlab/tests/test_mio.py
Log:
Moderately hackey small data element writing check

Modified: trunk/scipy/io/matlab/tests/test_mio.py
===================================================================
--- trunk/scipy/io/matlab/tests/test_mio.py	2008-12-14 02:30:09 UTC (rev 5246)
+++ trunk/scipy/io/matlab/tests/test_mio.py	2008-12-14 02:59:20 UTC (rev 5247)
@@ -25,7 +25,8 @@
 import scipy.sparse as SP
 
 from scipy.io.matlab.mio import loadmat, savemat, find_mat_file
-from scipy.io.matlab.mio5 import MatlabObject, MatFile5Writer
+from scipy.io.matlab.mio5 import MatlabObject, MatFile5Writer, \
+     Mat5NumericWriter
 
 test_data_path = join(dirname(__file__), 'data')
 
@@ -405,6 +406,7 @@
     mat_stream = StringIO()
     savemat(StringIO(), {'x': cells}, format='5')
 
+
 def test_writer_properties():
     # Tests getting, setting of properties of matrix writer
     mfw = MatFile5Writer(StringIO())
@@ -417,3 +419,19 @@
     yield assert_equal, mfw.long_field_names, False
     mfw.long_field_names = True
     yield assert_equal, mfw.long_field_names, True
+
+
+def test_use_small_element():
+    # Test whether we're using small data element or not
+    sio = StringIO()
+    # First check size for no sde for name
+    writer = Mat5NumericWriter(sio, np.zeros(10), 'aaaaa').write()
+    w_sz = sio.len
+    # Check small name results in largish difference in size
+    sio.truncate(0)
+    writer = Mat5NumericWriter(sio, np.zeros(10), 'aaaa').write()
+    yield assert_true, w_sz - sio.len > 4
+    # Whereas increasing name size makes less difference
+    sio.truncate(0)
+    writer = Mat5NumericWriter(sio, np.zeros(10), 'aaaaaa').write()
+    yield assert_true, sio.len - w_sz < 4




More information about the Scipy-svn mailing list