Skip to content

Commit 5a5170e

Browse files
fix tests for old numpy and 32bit
1 parent 6e08cc8 commit 5a5170e

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

pandas/tests/arrays/floating/test_to_numpy.py

Lines changed: 13 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
import pandas as pd
57
import pandas._testing as tm
68
from pandas.core.arrays import FloatingArray
@@ -148,8 +150,17 @@ def test_to_numpy_readonly():
148150
assert result.flags.writeable
149151

150152

151-
def test_asarray_readonly():
153+
@pytest.mark.skipif(not np_version_gt2, reason="copy keyword introduced in np 2.0")
154+
@pytest.mark.parametrize("dtype", [None, "float64"])
155+
def test_asarray_readonly(dtype):
152156
arr = pd.array([0.1, 0.2, 0.3], dtype="Float64")
153157
arr._readonly = True
154-
result = np.asarray(arr, copy=False)
158+
159+
result = np.asarray(arr, dtype=dtype)
160+
assert not result.flags.writeable
161+
162+
result = np.asarray(arr, dtype=dtype, copy=True)
163+
assert result.flags.writeable
164+
165+
result = np.asarray(arr, dtype=dtype, copy=False)
155166
assert not result.flags.writeable

pandas/tests/arrays/numpy_/test_numpy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import numpy as np
77
import pytest
88

9+
from pandas.compat.numpy import np_version_gt2
10+
911
from pandas.core.dtypes.dtypes import NumpyEADtype
1012

1113
import pandas as pd
@@ -168,9 +170,10 @@ def test_to_numpy_readonly():
168170
assert result.flags.writeable
169171

170172

173+
@pytest.mark.skipif(not np_version_gt2)
171174
@pytest.mark.parametrize("dtype", [None, "int64"])
172175
def test_asarray_readonly(dtype):
173-
arr = NumpyExtensionArray(np.array([1, 2, 3]))
176+
arr = NumpyExtensionArray(np.array([1, 2, 3], dtype="int64"))
174177
arr._readonly = True
175178
result = np.asarray(arr, dtype=dtype)
176179
assert not result.flags.writeable

0 commit comments

Comments
 (0)