1
1
import numpy as np
2
2
import pytest
3
3
4
- from pandas ._config import using_string_dtype
5
-
6
4
from pandas .compat import HAS_PYARROW
7
5
from pandas .compat .numpy import np_version_gt2
8
6
@@ -392,9 +390,6 @@ def test_to_numpy(arr, expected, zero_copy, index_or_series_or_array):
392
390
assert np .may_share_memory (result_nocopy1 , result_nocopy2 )
393
391
394
392
395
- @pytest .mark .xfail (
396
- using_string_dtype () and not HAS_PYARROW , reason = "TODO(infer_string)" , strict = False
397
- )
398
393
@pytest .mark .parametrize ("as_series" , [True , False ])
399
394
@pytest .mark .parametrize (
400
395
"arr" , [np .array ([1 , 2 , 3 ], dtype = "int64" ), np .array (["a" , "b" , "c" ], dtype = object )]
@@ -406,13 +401,13 @@ def test_to_numpy_copy(arr, as_series, using_infer_string):
406
401
407
402
# no copy by default
408
403
result = obj .to_numpy ()
409
- if using_infer_string and arr .dtype == object :
404
+ if using_infer_string and arr .dtype == object and obj . dtype . storage == "pyarrow" :
410
405
assert np .shares_memory (arr , result ) is False
411
406
else :
412
407
assert np .shares_memory (arr , result ) is True
413
408
414
409
result = obj .to_numpy (copy = False )
415
- if using_infer_string and arr .dtype == object :
410
+ if using_infer_string and arr .dtype == object and obj . dtype . storage == "pyarrow" :
416
411
assert np .shares_memory (arr , result ) is False
417
412
else :
418
413
assert np .shares_memory (arr , result ) is True
0 commit comments