Skip to content

Commit 404827b

Browse files
committed
BUG: Avoid asarray with copy= (it was added in 2.0)
1 parent 2183861 commit 404827b

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

pandas/core/arrays/numpy_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def __array__(
152152
) -> np.ndarray:
153153
if copy is not None:
154154
# Note: branch avoids `copy=None` for NumPy 1.x support
155-
return np.asarray(self._ndarray, dtype=dtype, copy=copy)
155+
return np.array(self._ndarray, dtype=dtype, copy=copy)
156156
return np.asarray(self._ndarray, dtype=dtype)
157157

158158
def __array_ufunc__(self, ufunc: np.ufunc, method: str, *inputs, **kwargs):

pandas/core/generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,7 @@ def __array__(
20192019
# Note: branch avoids `copy=None` for NumPy 1.x support
20202020
arr = np.asarray(values, dtype=dtype)
20212021
else:
2022-
arr = np.asarray(values, dtype=dtype, copy=copy)
2022+
arr = np.array(values, dtype=dtype, copy=copy)
20232023

20242024
if (
20252025
copy is not False

pandas/core/indexes/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ def __array__(self, dtype=None, copy=None) -> np.ndarray:
912912
# Note, that the if branch exists for NumPy 1.x support
913913
return np.asarray(self._data, dtype=dtype)
914914

915-
return np.asarray(self._data, dtype=dtype, copy=copy)
915+
return np.array(self._data, dtype=dtype, copy=copy)
916916

917917
def __array_ufunc__(self, ufunc: np.ufunc, method: str_t, *inputs, **kwargs):
918918
if any(isinstance(other, (ABCSeries, ABCDataFrame)) for other in inputs):

0 commit comments

Comments
 (0)