klamt-lab / straindesign

StrainDesign is a python package for the computational design of metabolic networks and based on COBRApy
Apache License 2.0
36 stars 6 forks source link

"IndexError: tuple index out of range" error with scipy>=1.13 #25

Closed Paulocracy closed 2 months ago

Paulocracy commented 3 months ago

Hello ;D At least with StrainDesign's integration in CNApy, I get the following error after the EFM compression when the problem is finally built:

    A_ineq_i, b_ineq_i, A_eq_i, b_eq_i, lb_i, ub_i, z_map_constr_ineq_i, z_map_constr_eq_i, z_map_vars_i = farkas_dualize(
  File "(...)/site-packages/straindesign/strainDesignProblem.py", line 850, in farkas_dualize
    A_ineq_f = sparse.vstack((A_ineq_d, c_d)).tocsr()
  File "(...)/site-packages/scipy/sparse/_construct.py", line 781, in vstack
    return _block([[b] for b in blocks], format, dtype, return_spmatrix=True)
  File "(...)/site-packages/scipy/sparse/_construct.py", line 952, in _block
    elif bcol_lengths[j] != A.shape[1]:
IndexError: tuple index out of range

This problem started to happen when I upgraded scipy from version 1.12 to a higher one (currently, 1.13 or 1.14, both don't work D:), reverting scipy to 1.12 also prevents this error from occuring :3 Up to now, I wasn't able to identify the relevant change introduced by the newer scipy releases (https://github.com/scipy/scipy/releases).

VonAlphaBisZulu commented 3 months ago

Thank you! For now, we could pin the version to be below 1.2, but longterm, we would want to find a real solution.

VonAlphaBisZulu commented 2 months ago

The error is caused by a type check by scipy that does not allow 1xn matrices to be appended with scalars. This type of problem is addressed in branch fix_scipy_sparse. Will be merged with main and released together with one or two other fixes and updates.