[python-hdf5storage] 147/152: Added additional tests to take the data read from MATLAB, send it back, read it back, and compare.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:24:43 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag 0.1
in repository python-hdf5storage.

commit 0c5e8c62e3243acef7890375f376bf28617cb93f
Author: Freja Nordsiek <fnordsie at gmail.com>
Date:   Sun Feb 16 04:27:55 2014 -0500

    Added additional tests to take the data read from MATLAB, send it back, read it back, and compare.
---
 tests/read_write_mat.m         |  4 ++++
 tests/test_read_from_matlab.py | 48 ++++++++++++++++++++++++++++++------------
 2 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/tests/read_write_mat.m b/tests/read_write_mat.m
new file mode 100644
index 0000000..a15651f
--- /dev/null
+++ b/tests/read_write_mat.m
@@ -0,0 +1,4 @@
+a = load('python_v7p3.mat')
+save('python_v7.mat','-struct','a','-v7')
+
+exit
diff --git a/tests/test_read_from_matlab.py b/tests/test_read_from_matlab.py
index 66be367..da6afdd 100644
--- a/tests/test_read_from_matlab.py
+++ b/tests/test_read_from_matlab.py
@@ -34,24 +34,37 @@ import hdf5storage
 
 from asserts import *
 
-mat_files = ['types_v7p3.mat', 'types_v7.mat']
+mat_files = ['types_v7p3.mat', 'types_v7.mat',
+             'python_v7p3.mat', 'python_v7.mat']
 for i in range(0, len(mat_files)):
     mat_files[i] = os.path.join(os.path.dirname(__file__), mat_files[i])
 
-script_name = os.path.join(os.path.dirname(__file__),
-                           'make_mat_with_all_types.m')
+script_names = ['make_mat_with_all_types.m', 'read_write_mat.m']
+for i in range(0, len(script_names)):
+    script_names[i] = os.path.join(os.path.dirname(__file__),
+                                   script_names[i])
+
+types_v7 = dict()
+types_v7p3 = dict()
+python_v7 = dict()
+python_v7p3 = dict()
 
-data_v7 = dict()
-data_v7p3 = dict()
 
 
 def setup_module():
     teardown_module()
-    matlab_command = "run('" + script_name + "')"
+    matlab_command = "run('" + script_names[0] + "')"
+    subprocess.check_output(['matlab', '-nosplash', '-nodesktop',
+                            '-nojvm', '-r', matlab_command])
+    scipy.io.loadmat(file_name=mat_files[1], mdict=types_v7)
+    hdf5storage.loadmat(file_name=mat_files[0], mdict=types_v7p3)
+
+    hdf5storage.savemat(file_name=mat_files[2], mdict=types_v7p3)
+    matlab_command = "run('" + script_names[1] + "')"
     subprocess.check_output(['matlab', '-nosplash', '-nodesktop',
                             '-nojvm', '-r', matlab_command])
-    scipy.io.loadmat(file_name=mat_files[1], mdict=data_v7)
-    hdf5storage.loadmat(file_name=mat_files[0], mdict=data_v7p3)
+    scipy.io.loadmat(file_name=mat_files[3], mdict=python_v7)
+    hdf5storage.loadmat(file_name=mat_files[2], mdict=python_v7p3)
 
 
 def teardown_module():
@@ -60,11 +73,20 @@ def teardown_module():
             os.remove(name)
 
 
-def test_read():
-    for k in (set(data_v7.keys()) - set(['__version__', '__header__', \
+def test_read_from_matlab():
+    for k in (set(types_v7.keys()) - set(['__version__', '__header__', \
             '__globals__'])):
-        yield check_variable, k
+        yield check_variable_from_matlab, k
+
+
+def test_to_matlab_back():
+    for k in set(types_v7p3.keys()):
+        yield check_variable_to_matlab_back, k
+
+
+def check_variable_from_matlab(name):
+    assert_equal_from_matlab(types_v7p3[name], types_v7[name])
 
 
-def check_variable(name):
-    assert_equal_from_matlab(data_v7p3[name], data_v7[name])
+def check_variable_to_matlab_back(name):
+    assert_equal_from_matlab(python_v7p3[name], python_v7[name])

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-hdf5storage.git



More information about the debian-science-commits mailing list