Skip to content

Fix NumPy 2.0 Warning, Require 2.0+ #427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ pyAMReX depends on the following popular third party software.
- [AMReX *development*](https://amrex-codes.github.io): we automatically download and compile a copy of AMReX
- [pybind11](https://github.com/pybind/pybind11/) 2.13.0+: we automatically download and compile a copy of pybind11 ([new BSD](https://github.com/pybind/pybind11/blob/master/LICENSE))
- [Python](https://python.org) 3.9+
- [Numpy](https://numpy.org) 1.15+
- [NumPy](https://numpy.org) 2.0+

Optional dependencies include:
- [mpi4py](https://mpi4py.readthedocs.io) 2.1+: for multi-node and/or multi-GPU execution
2 changes: 1 addition & 1 deletion docs/source/install/dependencies.rst
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ Please see installation instructions below.
- `pybind11 2.13.0+ <https://github.com/pybind/pybind11/>`__: we automatically download and compile a copy
- `Python 3.9+ <https://www.python.org>`__

- `numpy 1.15+ <https://numpy.org>`__
- `NumPy 2.0+ <https://numpy.org>`__

Optional dependencies include:

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
numpy>=1.15
numpy>=2.0
2 changes: 1 addition & 1 deletion src/amrex/extensions/Array4.py
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ def array4_to_numpy(self, copy=False, order="F"):
# This supports a device-to-host copy.
data = self.to_host()
else:
data = np.array(self, copy=False)
data = np.asarray(self, copy=False)

if order == "F":
return data.T
4 changes: 2 additions & 2 deletions src/amrex/extensions/ArrayOfStructs.py
Original file line number Diff line number Diff line change
@@ -35,9 +35,9 @@ def aos_to_numpy(self, copy=False):
# todo: validate of the to_host() returned object
# lifetime is always managed correctly by
# Python's GC - otherwise copy twice via copy=True
return np.array(self.to_host(), copy=False)
return np.asarray(self.to_host(), copy=False)
else:
return np.array(self, copy=False)
return np.asarray(self, copy=False)


def aos_to_cupy(self, copy=False):
2 changes: 1 addition & 1 deletion src/amrex/extensions/MultiFab.py
Original file line number Diff line number Diff line change
@@ -610,7 +610,7 @@ def __setitem__(self, index, value):
# (it needs to be 4-D).
# This converts value to an array if needed, and the [...] grabs a view so
# that the shape change below doesn't affect value.
value3d = np.array(value)[...]
value3d = np.asarray(value)[...]
global_shape = list(value3d.shape)
# The shape of 1 is added for the extra dimensions and when index is an integer
# (in which case the dimension was not in the input array).
4 changes: 2 additions & 2 deletions src/amrex/extensions/PODVector.py
Original file line number Diff line number Diff line change
@@ -32,9 +32,9 @@ def podvector_to_numpy(self, copy=False):
# todo: validate of the to_host() returned object
# lifetime is always managed correctly by
# Python's GC - otherwise copy twice via copy=True
return np.array(self.to_host(), copy=False)
return np.asarray(self.to_host(), copy=False)
else:
return np.array(self, copy=False)
return np.asarray(self, copy=False)
else:
raise ValueError("Vector is empty.")

4 changes: 2 additions & 2 deletions src/amrex/extensions/SmallMatrix.py
Original file line number Diff line number Diff line change
@@ -35,9 +35,9 @@ def smallmatrix_to_numpy(self, copy=False, order="F"):
import numpy as np

if copy:
data = np.array(self, copy=True)
data = np.asarray(self, copy=True)
else:
data = np.array(self, copy=False)
data = np.asarray(self, copy=False)

# TODO: Check self.order == "F" ?
if order == "F":