Skip to content

Commit

Permalink
add tests for sparse matrix loading (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
skjerns authored Mar 22, 2024
1 parent 02297ad commit c02c6e0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mat73/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.62'
__version__ = '0.63'
16 changes: 14 additions & 2 deletions tests/test_mat73.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
unittest.main()
Binary file added tests/testfile12.mat
Binary file not shown.

0 comments on commit c02c6e0

Please sign in to comment.