fix bug which happens when .mat data contains a sparse matrix in COO#23
fix bug which happens when .mat data contains a sparse matrix in COO#23jornbr merged 3 commits intoBoldingBruggeman:mainfrom
Conversation
|
Many thanks for reporting this and exploring a potential solution. It seems that recent scipy changes (scipy/scipy#21905) causes the matlab v5 arrays to be returned as just underneath That should address your issue and also maintain compatibilty with older scipy versions (in which case the cast does nothing). Could you test if that works for you, and if so, update your PR? |
|
Actually a cleaner code could likely just use |
8b56550 to
c1f7c2f
Compare
|
Hi @jornbr, thanks for your rapid response!. your code is more efficient and it resolves my issue. I have updated the PR. |
src/fabmos/transport/tmm.py
Outdated
| # MATLAB < 7.3 format | ||
| vardict = scipy.io.loadmat(fn, variable_names=(self._group_name,)) | ||
| A = vardict[self._group_name] | ||
| ## Convert COO matrix to CSR format if needed |
There was a problem hiding this comment.
CSR here should become CSC (or the comment could go, since the streamlined code is now pretty clear)
There was a problem hiding this comment.
absolutely! this is corrected.
|
Perfect - thanks for your contribution! |
when fabmos (v 1.0.1 from conda-forge) uses a old version of TMM (MITgcm_ECCO), a bug occurs because the .mat data has COO (coordinate) format, but the Python code is expecting a CSR (compressed sparse row) format. This PR converts the format to avoid the bug.