Skip to content

Commit 0c674e2

Browse files
committed
Fix NumPy 2.0 Warning
`np.array(..., copy=False)` to `np.asarray(..., copy=False)`. Bump requirements to NumPy 2.0+: we so far supported NumPy 1 & 2 in parallel, but NumPy 2 is widely enough deployed to require it now.
1 parent da8c9ad commit 0c674e2

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pyAMReX depends on the following popular third party software.
5454
- [AMReX *development*](https://amrex-codes.github.io): we automatically download and compile a copy of AMReX
5555
- [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))
5656
- [Python](https://python.org) 3.9+
57-
- [Numpy](https://numpy.org) 1.15+
57+
- [NumPy](https://numpy.org) 2.0+
5858

5959
Optional dependencies include:
6060
- [mpi4py](https://mpi4py.readthedocs.io) 2.1+: for multi-node and/or multi-GPU execution

docs/source/install/dependencies.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Please see installation instructions below.
1313
- `pybind11 2.13.0+ <https://github.com/pybind/pybind11/>`__: we automatically download and compile a copy
1414
- `Python 3.9+ <https://www.python.org>`__
1515

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

1818
Optional dependencies include:
1919

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
numpy>=1.15
1+
numpy>=2.0

src/amrex/extensions/Array4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def array4_to_numpy(self, copy=False, order="F"):
4040
# This supports a device-to-host copy.
4141
data = self.to_host()
4242
else:
43-
data = np.array(self, copy=False)
43+
data = np.asarray(self, copy=False)
4444

4545
if order == "F":
4646
return data.T

src/amrex/extensions/ArrayOfStructs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def aos_to_numpy(self, copy=False):
3535
# todo: validate of the to_host() returned object
3636
# lifetime is always managed correctly by
3737
# Python's GC - otherwise copy twice via copy=True
38-
return np.array(self.to_host(), copy=False)
38+
return np.asarray(self.to_host(), copy=False)
3939
else:
40-
return np.array(self, copy=False)
40+
return np.asarray(self, copy=False)
4141

4242

4343
def aos_to_cupy(self, copy=False):

src/amrex/extensions/MultiFab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ def __setitem__(self, index, value):
610610
# (it needs to be 4-D).
611611
# This converts value to an array if needed, and the [...] grabs a view so
612612
# that the shape change below doesn't affect value.
613-
value3d = np.array(value)[...]
613+
value3d = np.asarray(value)[...]
614614
global_shape = list(value3d.shape)
615615
# The shape of 1 is added for the extra dimensions and when index is an integer
616616
# (in which case the dimension was not in the input array).

src/amrex/extensions/PODVector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def podvector_to_numpy(self, copy=False):
3232
# todo: validate of the to_host() returned object
3333
# lifetime is always managed correctly by
3434
# Python's GC - otherwise copy twice via copy=True
35-
return np.array(self.to_host(), copy=False)
35+
return np.asarray(self.to_host(), copy=False)
3636
else:
37-
return np.array(self, copy=False)
37+
return np.asarray(self, copy=False)
3838
else:
3939
raise ValueError("Vector is empty.")
4040

src/amrex/extensions/SmallMatrix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def smallmatrix_to_numpy(self, copy=False, order="F"):
3535
import numpy as np
3636

3737
if copy:
38-
data = np.array(self, copy=True)
38+
data = np.asarray(self, copy=True)
3939
else:
40-
data = np.array(self, copy=False)
40+
data = np.asarray(self, copy=False)
4141

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

0 commit comments

Comments
 (0)