Skip to content

Commit

Permalink
Update calls to numpy.reshape to avoid deprecation warnings (#433)
Browse files Browse the repository at this point in the history
NumPy 2.1 deprecates the `newshape` argument of the `reshape` function.
Instead, one should use the positional-only argument `shape`. Every call
in Psydac has been updated accordingly. This closes #432.
  • Loading branch information
FrederikSchnack authored Sep 18, 2024
1 parent 43833c2 commit 516363e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion psydac/fem/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def eval_fields(self, grid, *fields, weights=None, npts_per_cell=None, overlap=0
npts_per_cell = (npts_per_cell,) * self.ldim
for i in range(self.ldim):
ncells_i = len(self.breaks[i]) - 1
grid[i] = np.reshape(grid[i], newshape=(ncells_i, npts_per_cell[i]))
grid[i] = np.reshape(grid[i], (ncells_i, npts_per_cell[i]))
out_fields = self.eval_fields_regular_tensor_grid(grid, *fields, weights=weights, overlap=overlap)
# return a list
return [np.ascontiguousarray(out_fields[..., i]) for i in range(len(fields))]
Expand Down
6 changes: 3 additions & 3 deletions psydac/mapping/discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def jac_mat_grid(self, grid, npts_per_cell=None, overlap=0):
npts_per_cell = (npts_per_cell,) * self.ldim
for i in range(self.ldim):
ncells_i = len(self.space.breaks[i]) - 1
grid[i] = np.reshape(grid[i], newshape=(ncells_i, npts_per_cell[i]))
grid[i] = np.reshape(grid[i], (ncells_i, npts_per_cell[i]))
jac_mats = self.jac_mat_regular_tensor_grid(grid, overlap=overlap)
return jac_mats

Expand Down Expand Up @@ -413,7 +413,7 @@ def inv_jac_mat_grid(self, grid, npts_per_cell=None, overlap=0):
npts_per_cell = (npts_per_cell,) * self.ldim
for i in range(self.ldim):
ncells_i = len(self.space.breaks[i]) - 1
grid[i] = np.reshape(grid[i], newshape=(ncells_i, npts_per_cell[i]))
grid[i] = np.reshape(grid[i], (ncells_i, npts_per_cell[i]))
inv_jac_mats = self.inv_jac_mat_regular_tensor_grid(grid, overlap=overlap)
return inv_jac_mats

Expand Down Expand Up @@ -584,7 +584,7 @@ def jac_det_grid(self, grid, npts_per_cell=None, overlap=0):
npts_per_cell = (npts_per_cell,) * self.ldim
for i in range(self.ldim):
ncells_i = len(self.space.breaks[i]) - 1
grid[i] = np.reshape(grid[i], newshape=(ncells_i, npts_per_cell[i]))
grid[i] = np.reshape(grid[i], (ncells_i, npts_per_cell[i]))
jac_dets = self.jac_det_regular_tensor_grid(grid, overlap=overlap)
return jac_dets

Expand Down

0 comments on commit 516363e

Please sign in to comment.