def test_func_read(): func_eg = pjoin(test_data_path, 'testfunc_7.4_GLNX86.mat') rdr = MatFile5Reader_future(file(func_eg, 'rb')) d = rdr.get_variables() yield assert_true, isinstance(d['testfunc'], MatlabFunction) stream = StringIO() wtr = MatFile5Writer(stream, oned_as='row') yield assert_raises, MatWriteError, wtr.put_variables, d
def test_func_read(): func_eg = pjoin(test_data_path, 'testfunc_7.4_GLNX86.mat') fp = open(func_eg, 'rb') rdr = MatFile5Reader(fp) d = rdr.get_variables() fp.close() assert_(isinstance(d['testfunc'], MatlabFunction)) stream = BytesIO() wtr = MatFile5Writer(stream) assert_raises(MatWriteError, wtr.put_variables, d)
def test_writer_properties(): # Tests getting, setting of properties of matrix writer mfw = MatFile5Writer(BytesIO(), oned_as='row') yield assert_equal, mfw.global_vars, [] mfw.global_vars = ['avar'] yield assert_equal, mfw.global_vars, ['avar'] yield assert_equal, mfw.unicode_strings, False mfw.unicode_strings = True yield assert_equal, mfw.unicode_strings, True yield assert_equal, mfw.long_field_names, False mfw.long_field_names = True yield assert_equal, mfw.long_field_names, True
def test_writer_properties(): # Tests getting, setting of properties of matrix writer mfw = MatFile5Writer(BytesIO()) assert_equal(mfw.global_vars, []) mfw.global_vars = ['avar'] assert_equal(mfw.global_vars, ['avar']) assert_equal(mfw.unicode_strings, False) mfw.unicode_strings = True assert_equal(mfw.unicode_strings, True) assert_equal(mfw.long_field_names, False) mfw.long_field_names = True assert_equal(mfw.long_field_names, True)
def test_use_small_element(): # Test whether we're using small data element or not sio = StringIO() wtr = MatFile5Writer(sio, oned_as='column') # First check size for no sde for name arr = np.zeros(10) wtr.put_variables({'aaaaa': arr}) w_sz = sio.len # Check small name results in largish difference in size sio.truncate(0) wtr.put_variables({'aaaa': arr}) yield assert_true, w_sz - sio.len > 4 # Whereas increasing name size makes less difference sio.truncate(0) wtr.put_variables({'aaaaaa': arr}) yield assert_true, sio.len - w_sz < 4
def test_use_small_element(): # Test whether we're using small data element or not sio = BytesIO() wtr = MatFile5Writer(sio) # First check size for no sde for name arr = np.zeros(10) wtr.put_variables({'aaaaa': arr}) w_sz = len(sio.getvalue()) # Check small name results in largish difference in size sio.truncate(0) sio.seek(0) wtr.put_variables({'aaaa': arr}) assert_(w_sz - len(sio.getvalue()) > 4) # Whereas increasing name size makes less difference sio.truncate(0) sio.seek(0) wtr.put_variables({'aaaaaa': arr}) assert_(len(sio.getvalue()) - w_sz < 4)