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

Numpy 1.24 breaks builtin type aliases #1305

Closed marvinvanaalst closed 1 year ago

marvinvanaalst commented 1 year ago

Problem description

The numpy people marked aliases of builtin types like np.bool or np.float as deprecated in version 1.20.0. They are effectively deprecated with version 1.24.0 which was just released.

This leads to a bunch of AttributeErrors, like

AttributeError: module 'numpy' has no attribute 'float'

Your setup.cfg states compatability for numpy ~=1.13 which includes all minor versions >= 13 and thus causes CI to crash on this (but that's on the numpy folks).

I've started fixing this in my fork but noticed during the tests that some of the dependencies like osqp have the same issue.

The best short-term fix is probably to exclude numpy versions >=1.24 until all the dependencies have caught up on this.

cdiener commented 1 year ago

Yes that makes sense. Feel free to send in a PR that pins numpy to a lower version in the setup.cfg.

woutervh commented 1 year ago

Feel free to send in a PR that pins numpy to a lower version in the setup.cfg. This is the wrong solution. It hides the problem of using deprecated numpy-calls, The title wrongly suggests that numpy needs to fix an issue,

Pinning numpy to a lower-version only makes sense when the problem arises in the thirdparty package you cannot control.

in this case the problem is only a single np.float in https://github.com/opencobra/cobrapy/blob/devel/src/cobra/io/dict.py#L71

Midnighter commented 1 year ago

PR welcome 😉

marvinvanaalst commented 1 year ago

Feel free to send in a PR that pins numpy to a lower version in the setup.cfg. This is the wrong solution. It hides the problem of using deprecated numpy-calls, The title wrongly suggests that numpy needs to fix an issue,

Pinning numpy to a lower-version only makes sense when the problem arises in the thirdparty package you cannot control.

in this case the problem is only a single np.float in https://github.com/opencobra/cobrapy/blob/devel/src/cobra/io/dict.py#L71

This problem is not confined to cobrapy, but also occurs for example in osqp, see this issue, which is a dependency of cobrapy. Since the corresponding PR has not been merged yet, I don't see a better solution at this point in time

PR welcome :wink:

The PR is here :slightly_smiling_face:

Midnighter commented 1 year ago

Ah, great. I'm not involved in the OSQP project so I can't help it along unfortunately.

cdiener commented 1 year ago

It usually takes a while, but the OSQP folks have always come through in the past.

cdiener commented 1 year ago

This has now been fixed in osqp==0.6.2.post9 and cobrapy==0.26.3. I will remove the numpy pin for the next release.