ISISNeutronMuon / MDANSE

MDANSE: Molecular Dynamics Analysis for Neutron Scattering Experiments
https://www.isis.stfc.ac.uk/Pages/MDANSEproject.aspx
GNU General Public License v3.0
18 stars 4 forks source link

[BUG] Potential problems with Numpy 2 #479

Closed MBartkowiakSTFC closed 2 days ago

MBartkowiakSTFC commented 5 days ago

Description of the error Since 16 June 2024, Numpy 2 is available on PyPI, and the number of users who have this version installed will gradually increase.

The list of problems that need to be addressed before we can switch to the new Numpy includes:

  1. Import errors from rdkit. In the rdkit pyproject.toml, the requirement list includes "oldest-supported-numpy". Trying to import rdkit when Numpy 2 is installed results in messages like this one:
    from rdkit.DataStructs import cDataStructs
    AttributeError: _ARRAY_API not found
  2. IOutputVariable inherits numpy.ndarray. The API changes at the moment result in just warning being issued, mainly due to the __array_wrap__ implementation in IOutputVariable not conforming to the requirements of Numpy 2. The full unit test suite of MDANSE at the moment produces over 180000 warnings.

Describe the expected result It would be the best if we could smoothly switch to Numpy 2, before the old branch stops being supported.

Describe the actual result N/A

Suggested fix Temporary solution: restrict the numpy version in MDANSE requirements to <2. Long-term solution: rewrite IOutputVariable so it does not inherit ndarray. It should still use the numpy.ndarray internally, but there is no need to inherit it.

Additional details N/A