Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
crusaderky committed Nov 27, 2024
1 parent 90fb03c commit 54dbd58
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions array_api_compat/common/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Callable, Optional, Union, Any
from typing import Callable, Literal, Optional, Union, Any
from ._typing import Array, Device

import sys
Expand Down Expand Up @@ -819,16 +819,17 @@ def _parse_copy_param(x, copy: bool | None | Literal["_force_false"]) -> bool:
"""Preprocess and validate a copy parameter, in line with the same
parameter in np.asarray(), np.astype(), etc.
"""
if copy is None:
return not is_writeable_array(x)
if copy is False:
if copy is True:
return True
elif copy is False:
if not is_writeable_array(x):
raise ValueError("Cannot avoid modifying parameter in place")
return False
elif copy is None:
return not is_writeable_array(x)
elif copy == "_force_false":
return False
elif copy is not True:
raise ValueError(f"Invalid value for copy: {copy!r}")
return copy
raise ValueError(f"Invalid value for copy: {copy!r}")


_undef = object()
Expand Down

0 comments on commit 54dbd58

Please sign in to comment.