From c02c6e0b7046e45e432091bd96e239fa2fd9ba01 Mon Sep 17 00:00:00 2001 From: Simon Kern <14980558+skjerns@users.noreply.github.com> Date: Fri, 22 Mar 2024 16:57:29 +0100 Subject: [PATCH] add tests for sparse matrix loading (#54) --- mat73/version.py | 2 +- tests/test_mat73.py | 16 ++++++++++++++-- tests/testfile12.mat | Bin 0 -> 121872 bytes 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 tests/testfile12.mat diff --git a/mat73/version.py b/mat73/version.py index d1de237..dba4560 100644 --- a/mat73/version.py +++ b/mat73/version.py @@ -1 +1 @@ -__version__ = '0.62' +__version__ = '0.63' diff --git a/tests/test_mat73.py b/tests/test_mat73.py index f7e5c05..3ee9d2b 100644 --- a/tests/test_mat73.py +++ b/tests/test_mat73.py @@ -34,7 +34,7 @@ class Testing(unittest.TestCase): def setUp(self): """make links to test files and make sure they are present""" - for i in range(1, 12): + for i in range(1, 13): file = 'testfile{}.mat'.format(i) if not os.path.exists(file): file = os.path.join('./tests', file) @@ -414,6 +414,18 @@ def test_file11_specificvars_cells(self): data = mat73.loadmat(self.testfile11, only_include=['bar']) assert len(data)==0 + def test_file12_sparse_matrix_fix(self): + """some sparse matrices could not be loaded. check if it now works""" + # check regular loading works + import scipy + data = mat73.loadmat(self.testfile12) + struct_sparse = data['rec_img']['fwd_model']['stimulation'] + sparse_type = scipy.sparse.csc_matrix + assert isinstance(struct_sparse[0]['meas_pattern'], sparse_type) + assert isinstance(struct_sparse[0]['stim_pattern'], sparse_type) + assert isinstance(struct_sparse[0]['stimulation'], str) + + if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/tests/testfile12.mat b/tests/testfile12.mat new file mode 100644 index 0000000000000000000000000000000000000000..57f9dbaa1b95fc2b81194a6fa984713b8ff2d422 GIT binary patch literal 121872 zcmeHw4R~Z%dEU`#*E`s2GsXrK7n<8bshVzV*{qE)w0qaa_7J@G1U5nBNvfHZW_Prf zMq^2fwI)1FX_{wnAt;1^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