idefix-code / idefix

A fast finite volume code designed to run on many architectures, such as GPU, CPU and manycores, using Kokkos.
https://idefix.readthedocs.io/
Other
28 stars 19 forks source link

Update to numpy 2+ #283

Closed vdbma closed 2 weeks ago

vdbma commented 2 weeks ago

idfx_io.py used np.product which is deprecated in numpy >= 2.0 (https://numpy.org/devdocs/numpy_2_0_migration_guide.html). Replaced by np.prod.

neutrinoceros commented 2 weeks ago

@vdbma I would also recommend adding the following patch to detect numpy 2 incompatible code uses at commit time:

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 06fe7210..85926501 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -33,6 +33,7 @@ repos:
         - F # pyflakes
         - B # flake8-bugbear
         - I # isort
+        - NPY # numpy-specific rules

   - repo: https://github.com/neutrinoceros/inifix
     rev: v5.0.2

furthermore, you'll need to rebase your branch on top of, and target develop for this PR (linting issues are already solved there)