Skip to content

Commit ad375dc

Browse files
committed
Fix CopyMode
1 parent 362c48a commit ad375dc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

array_api_compat/numpy/_aliases.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ def asarray(
8888
"""
8989
_helpers._check_device(np, device)
9090

91+
# None is unsupported in NumPy 1.0, but we can use an internal enum
92+
# False in NumPy 1.0 means None in NumPy 2.0 and in the Array API
9193
if copy is None:
92-
np1_copy = np._CopyMode.IF_NEEDED # type: ignore[attr-defined]
93-
elif copy:
94-
np1_copy = np._CopyMode.ALWAYS # type: ignore[attr-defined]
95-
else:
96-
np1_copy = np._CopyMode.NEVER # type: ignore[attr-defined]
94+
copy = np._CopyMode.IF_NEEDED # type: ignore[assignment,attr-defined]
95+
elif copy is False:
96+
copy = np._CopyMode.NEVER # type: ignore[assignment,attr-defined]
9797

98-
return np.array(obj, copy=np1_copy, dtype=dtype, **kwargs)
98+
return np.array(obj, copy=copy, dtype=dtype, **kwargs)
9999

100100

101101
def astype(

0 commit comments

Comments
 (0)