flatironinstitute / CaImAn

Computational toolbox for large scale Calcium Imaging Analysis, including movie handling, motion correction, source extraction, spike deconvolution and result visualization.
https://caiman.readthedocs.io
GNU General Public License v2.0
640 stars 370 forks source link

scipy.sparse.csc` namespace is deprecated. #1235

Closed EricThomson closed 1 year ago

EricThomson commented 1 year ago

Hauling this over from a discussion thread.

Something to do soon: turn off all the warnings and fix them.

This would be a great first issue for anyone that is interested in contributing to Caiman. :smile:

Discussed in https://github.com/flatironinstitute/CaImAn/discussions/1232

Originally posted by **AB0913** November 17, 2023 Hi everyone! I am attempting to run the demo script for multisession registration, but ran into this error: DeprecationWarning: Please use `csc_matrix` from the `scipy.sparse` namespace, the `scipy.sparse.csc` namespace is deprecated. data = pickle.load(infile) I am still fairly new to Python, so I wasn't sure how I should update to prevent to not rely on this deprecated function? Thank you!!
pgunn commented 1 year ago

First version of scipy with this namespace change is 1.7.2 (I think) and we already require >1.10.1 so there's no need to change pins.

pgunn commented 1 year ago

Ah, this is unfortunate. The only instance of scipy.sparse.csc.csc_matrix in the code is in the comparison test (and this is not that - we should fix it anyway though).

I think we need to update alignment.pickle on our infrastructure to have a different class name for some of its internals so when it gets unpickled it doesn't go through the codepath that issues the deprecation warning.

pgunn commented 1 year ago

(removed "good first issue" because it's actually not something anyone external could fix)

pgunn commented 1 year ago

It looks like it's actually not fixable! I tried copying the csc_matrix to a new object and it had the same deprecated type, and I then tried making a new empty csc_matrix and it has the deprecated type.

>>> empty_csc = scipy.sparse.csc_matrix([0,0])
>>> type(empty_csc)
<class 'scipy.sparse._csc.csc_matrix'>

I'll write to them, but I suspect this is just a deprecation warning we'll have to deal with so long as we ever pickle/unpickle these things unless they change things upstream.

pgunn commented 1 year ago

https://github.com/scipy/scipy/issues/19566

pgunn commented 1 year ago

Looks like it's fixable after all. I'm uploading a fixed picklefile now.

pgunn commented 1 year ago

Fixed by uploading a new alignment.pickle after converting it