Skip to content

Commit 467f107

Browse files
committed
MAINT: Adjust the codebase to the new np.array copy keyword meaning
1 parent db11e25 commit 467f107

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

Diff for: pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ def to_numpy(
19781978
dtype = np.dtype(dtype)
19791979
result = self._mgr.as_array(dtype=dtype, copy=copy, na_value=na_value)
19801980
if result.dtype is not dtype:
1981-
result = np.array(result, dtype=dtype, copy=False)
1981+
result = np.asarray(result, dtype=dtype)
19821982

19831983
return result
19841984

Diff for: pandas/tests/arrays/test_datetimelike.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ def test_array_interface(self, timedelta_index):
956956
expected = arr._ndarray
957957
assert result is expected
958958
tm.assert_numpy_array_equal(result, expected)
959-
result = np.array(arr, copy=False)
959+
result = np.array(arr, copy=np._CopyMode.IF_NEEDED)
960960
assert result is expected
961961
tm.assert_numpy_array_equal(result, expected)
962962

@@ -965,7 +965,7 @@ def test_array_interface(self, timedelta_index):
965965
expected = arr._ndarray
966966
assert result is expected
967967
tm.assert_numpy_array_equal(result, expected)
968-
result = np.array(arr, dtype="timedelta64[ns]", copy=False)
968+
result = np.array(arr, dtype="timedelta64[ns]", copy=np._CopyMode.IF_NEEDED)
969969
assert result is expected
970970
tm.assert_numpy_array_equal(result, expected)
971971
result = np.array(arr, dtype="timedelta64[ns]")

Diff for: pandas/tests/extension/array_with_attr/array.py

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def __init__(self, values, attr=None) -> None:
4949

5050
@classmethod
5151
def _from_sequence(cls, scalars, *, dtype=None, copy=False):
52+
copy = np._CopyMode.ALWAYS if copy else np._CopyMode.IF_NEEDED
5253
data = np.array(scalars, dtype="float64", copy=copy)
5354
return cls(data)
5455

0 commit comments

Comments
 (0)