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