Skip to content

Commit a1f8ff4

Browse files
authored
Merge pull request #288 from mfem/numpy2_dev
Fix depercation warnings with Numpy 2.
2 parents 67b4b76 + f7715df commit a1f8ff4

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

mfem/_par/coefficient.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace mfem {
5353
%pythonprepend MatrixConstantCoefficient::MatrixConstantCoefficient(const DenseMatrix &m) %{
5454
try:
5555
import numpy as np
56-
value = np.array(m, copy=False, dtype=float)
56+
value = np.asarray(m, dtype=float)
5757
can_np_array = True
5858
except:
5959
can_np_array = False
@@ -68,7 +68,7 @@ namespace mfem {
6868
%pythonprepend VectorConstantCoefficient::VectorConstantCoefficient(const Vector &v) %{
6969
try:
7070
import numpy as np
71-
value = np.array(v, copy=False, dtype=float).flatten()
71+
value = np.asarray(v, dtype=float).flatten()
7272
can_np_array = True
7373
except:
7474
can_np_array = False

mfem/_par/mesh.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def FindPoints(self, pp, warn=True, inv_trans=None):
269269
import numpy as np
270270
import mfem.par as mfem
271271

272-
pp = np.array(pp, copy=False, dtype=float).transpose()
272+
pp = np.asarray(pp, dtype=float).transpose()
273273
M = mfem.DenseMatrix(pp.shape[0], pp.shape[1])
274274
M.Assign(pp)
275275
elem_ids = mfem.intArray()

mfem/_ser/coefficient.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace mfem {
5252
%pythonprepend MatrixConstantCoefficient::MatrixConstantCoefficient(const DenseMatrix &m) %{
5353
try:
5454
import numpy as np
55-
value = np.array(m, copy=False, dtype=float)
55+
value = np.asarray(m, dtype=float)
5656
can_np_array = True
5757
except:
5858
can_np_array = False
@@ -67,7 +67,7 @@ namespace mfem {
6767
%pythonprepend VectorConstantCoefficient::VectorConstantCoefficient(const Vector &v) %{
6868
try:
6969
import numpy as np
70-
value = np.array(v, copy=False, dtype=float).flatten()
70+
value = np.asarray(v, dtype=float).flatten()
7171
can_np_array = True
7272
except:
7373
can_np_array = False

mfem/_ser/mesh.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def FindPoints(self, pp, warn=True, inv_trans=None):
274274
import numpy as np
275275
import mfem.ser as mfem
276276

277-
pp = np.array(pp, copy=False, dtype=float).transpose()
277+
pp = np.asarray(pp, dtype=float).transpose()
278278
M = mfem.DenseMatrix(pp.shape[0], pp.shape[1])
279279
M.Assign(pp)
280280
elem_ids = mfem.intArray()

mfem/common/findpoints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def do_findpoints(mesh, *args):
2828
return v, elem_id, ips
2929

3030
def eval_at_points(gf, *args):
31-
args = [np.atleast_1d(np.array(t, copy=False)) for t in args]
31+
args = [np.atleast_1d(np.asarray(t)) for t in args]
3232
mesh = gf.FESpace().Mesh()
3333
v, elem_id, ips = findpoints(mesh, *args)
3434

@@ -45,6 +45,6 @@ def findpoints(mesh, *args):
4545
elif len(args) != 1 and sdim == 1:
4646
assert False, "SpaceDimension = 3, pass x"
4747
else:
48-
args = [np.atleast_1d(np.array(t, copy=False)) for t in args]
48+
args = [np.atleast_1d(np.array(t)) for t in args]
4949
return do_findpoints(mesh, *args)
5050

mfem/common/parcsr_extra.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ def ResetHypreDiag(M, idx, value=1.0):
504504
np.min(jcn), np.max(jcn), (m, n))
505505
raise
506506

507-
idx = np.array(idx, dtype=int, copy=False)
507+
idx = np.asarray(idx, dtype=int)
508508
ii = idx[np.logical_and(idx >= ilower, idx <= iupper)]
509509
mat[ii-ilower, ii] = value
510510
# for ii in idx:
@@ -529,7 +529,7 @@ def ResetHypreRow(M, idx):
529529
n = M.N()
530530
from scipy.sparse import coo_matrix, lil_matrix
531531

532-
k = np.in1d(irn, idx)
532+
k = np.isin(irn, idx)
533533
data[k] = 0.0
534534

535535
mat = coo_matrix((data, (irn-ilower, jcn)), shape=(m, n)).tocsr()
@@ -553,7 +553,7 @@ def ResetHypreCol(M, idx):
553553
n = M.N()
554554
from scipy.sparse import coo_matrix, lil_matrix
555555

556-
k = np.in1d(jcn, idx)
556+
k = np.isin(jcn, idx)
557557
data[k] = 0.0
558558

559559
mat = coo_matrix((data, (irn-ilower, jcn)), shape=(m, n)).tocsr()
@@ -583,7 +583,7 @@ def ReadHypreDiag(M, idx):
583583
np.min(jcn), np.max(jcn), (m, n))
584584
raise
585585

586-
idx = np.array(idx, dtype=int, copy=False)
586+
idx = np.asarray(idx, dtype=int)
587587
ii = idx[np.logical_and(idx >= ilower, idx <= iupper)]
588588

589589
tmp = mat[ii-ilower, ii].toarray().flatten()

0 commit comments

Comments
 (0)