opencobra / cobrapy

COBRApy is a package for constraint-based modeling of metabolic networks.
http://opencobra.github.io/cobrapy/
GNU General Public License v2.0
467 stars 218 forks source link

[BUG] Numpy update broke load_matlab_model #1406

Closed cjrodriguez98 closed 2 months ago

cjrodriguez98 commented 2 months ago

Is there an existing issue for this?

Problem description

I am trying to load a matlab model into cobrapy in a fresh enviroment and I am getting a numpy exception.

cobra.io.load_matlab_model(Path('/scratch/cjrodriguezf/jobs/cancer/signaling_data', 'Human-GEM-1.14.0.mat')) Traceback (most recent call last): File "", line 1, in File "/scratch/cjrodriguezf/enviroments/cancer/lib/python3.9/site-packages/cobra/io/mat.py", line 341, in load_matlab_model return from_mat_struct(data[possible_name], model_id=possible_name, inf=inf) File "/scratch/cjrodriguezf/enviroments/cancer/lib/python3.9/site-packages/cobra/io/mat.py", line 872, in from_mat_struct if np.sctype2char(m["subSystems"][0, 0][0][0]) == "O" and isinstance( File "/scratch/cjrodriguezf/enviroments/cancer/lib/python3.9/site-packages/numpy/init.py", line 397, in getattr raise AttributeError( AttributeError: np.sctype2char was removed in the NumPy 2.0 release. Use np.dtype(obj).char instead.

Code sample

Code run:

cobra.io.load_matlab_model(Path('/scratch/cjrodriguezf/jobs/cancer/signaling_data', 'Human-GEM-1.14.0.mat'))

Traceback:

Traceback (most recent call last): File "", line 1, in File "/scratch/cjrodriguezf/enviroments/cancer/lib/python3.9/site-packages/cobra/io/mat.py", line 341, in load_matlab_model return from_mat_struct(data[possible_name], model_id=possible_name, inf=inf) File "/scratch/cjrodriguezf/enviroments/cancer/lib/python3.9/site-packages/cobra/io/mat.py", line 872, in from_mat_struct if np.sctype2char(m["subSystems"][0, 0][0][0]) == "O" and isinstance( File "/scratch/cjrodriguezf/enviroments/cancer/lib/python3.9/site-packages/numpy/init.py", line 397, in getattr raise AttributeError( AttributeError: np.sctype2char was removed in the NumPy 2.0 release. Use np.dtype(obj).char instead.

Environment

Python 3.9.19 cobra 0.29.0 numpy 2.0.2

Anything else?

No response

cdiener commented 2 months ago

Hi, this has already been fixed in the code base but we should make a release to deploy it. I will send one in.

cjrodriguez98 commented 2 months ago

Thanks!