Repository: skjerns/mat7.3 (language: python)

Issue:
Fix sparse bug #51
This would probably be a solution, but I am not sure, the elif case below might have to be moved to the top level too
Does not load sparse matrix correctly
**Describe the bug**

The sparse matrix `A` is not properly loaded

```python
>>> data = mat73.loadmat('DataFull_128x45.mat')
{'A': {'data': None, 'ir': None, 'jc': None}, 'm': array([[0.04562512, 0.03787717, 0.04324344, ..., 0.03325841, 0.02450304,
        0.03...3638235, 0.03459222,
        0.03479418]]), 'normA': array(694.51590391)}
```

```python
>>> h5py.File('DataFull_128x45.mat')["A"]["data"]
<HDF5 dataset "data": shape (8537187,), type "<f8">
```

**Provide sample file**

Taken from https://zenodo.org/records/1254210  see [DataFull_128x45.mat](https://zenodo.org/records/1254210/files/DataFull_128x45.mat?download=1)



Discussion / hints:
Thanks! The tests are passing, so it might work I guess? I'll see if I can find some way to test it thoroughly.

Does this solve #51 ?
It would solve my issue (#52) I think based on the debugging I have done and that threw the same error.
> Thanks! The tests are passing, so it might work I guess? I'll see if I can find some way to test it thoroughly.
> 
> Does this solve #51 ?

From reading the committed codes, without testing, i assume yes. At least everything is plausible.
thanks! that seems to have no side effects :)
Duplicate of #51 

Fix patch:
diff --git a/mat73/version.py b/mat73/version.py
index d1de237..dba4560 100644
--- a/mat73/version.py
+++ b/mat73/version.py
@@ -1,1 +1,1 @@
-__version__ = '0.62'
+__version__ = '0.63'


Test patch:
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 0000000..57f9dba
Binary files /dev/null and b/tests/testfile12.mat differ