Skip to content

Commit 31d7d72

Browse files
fixup test for older numpy
1 parent 230180c commit 31d7d72

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pandas/tests/copy_view/test_array.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
import pytest
33

4+
from pandas.compat.numpy import np_version_gt2
5+
46
from pandas import (
57
DataFrame,
68
Series,
@@ -138,8 +140,11 @@ def test_dataframe_multiple_numpy_dtypes():
138140
assert not np.shares_memory(arr, get_array(df, "a"))
139141
assert arr.flags.writeable is True
140142

141-
with pytest.raises(ValueError, match="Unable to avoid copy while creating"):
142-
arr = np.array(df, copy=False)
143+
if not np_version_gt2:
144+
# copy=False semantics are only supported in NumPy>=2.
145+
146+
with pytest.raises(ValueError, match="Unable to avoid copy while creating"):
147+
arr = np.array(df, copy=False)
143148

144149
arr = np.array(df, copy=True)
145150
assert arr.flags.writeable is True

0 commit comments

Comments
 (0)