Skip to content

Commit

Permalink
Fixed some copy keyword arguments to adhere to new numpy standard
Browse files Browse the repository at this point in the history
  • Loading branch information
david-zwicker committed Jun 16, 2024
1 parent 27e4a8a commit 6de363f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pde/fields/datafield_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(
# use full data without copying (unless necessary)
if data is None or isinstance(data, str):
raise ValueError("`data` must be supplied if with_ghost_cells==True")
data_arr = number_array(data, dtype=dtype, copy=False)
data_arr = number_array(data, dtype=dtype, copy=None)
super().__init__(grid, data=data_arr, label=label)

else:
Expand Down Expand Up @@ -108,7 +108,7 @@ def __init__(

else:
# initialize empty data and set the valid data
data_arr = number_array(data, dtype=dtype, copy=False)
data_arr = number_array(data, dtype=dtype, copy=None)
empty_data = np.empty(full_shape, dtype=data_arr.dtype)
super().__init__(grid, data=empty_data, label=label)
self.data = data_arr
Expand Down
7 changes: 4 additions & 3 deletions pde/tools/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def preserve_scalars(method: TFunc) -> TFunc:

@functools.wraps(method)
def wrapper(self, *args):
args = [number_array(arg, copy=False) for arg in args]
args = [number_array(arg, copy=None) for arg in args]
if args[0].ndim == 0:
args = [arg[None] for arg in args]
return method(self, *args)[0]
Expand Down Expand Up @@ -362,7 +362,7 @@ def get_common_dtype(*args):


def number_array(
data: ArrayLike, dtype: DTypeLike = None, copy: bool = True
data: ArrayLike, dtype: DTypeLike = None, copy: bool | None = None
) -> np.ndarray:
"""convert an array with arbitrary dtype either to np.double or np.cdouble
Expand All @@ -375,7 +375,8 @@ def number_array(
it will be determined from `data` automatically.
copy (bool):
Whether the data must be copied (in which case the original array is left
untouched). Note that data will always be copied when changing the dtype.
untouched). The default `None` implies that data is only copied if
necessary, e.g., when changing the dtype.
Returns:
:class:`~numpy.ndarray`: An array with the correct dtype
Expand Down

0 comments on commit 6de363f

Please sign in to comment.