11import numpy as np
22import pytest
33
4- from pandas ._config import using_string_dtype
5-
64from pandas .compat import HAS_PYARROW
75from pandas .compat .numpy import np_version_gt2
86
@@ -391,9 +389,6 @@ def test_to_numpy(arr, expected, zero_copy, index_or_series_or_array):
391389 assert np .may_share_memory (result_nocopy1 , result_nocopy2 )
392390
393391
394- @pytest .mark .xfail (
395- using_string_dtype () and not HAS_PYARROW , reason = "TODO(infer_string)" , strict = False
396- )
397392@pytest .mark .parametrize ("as_series" , [True , False ])
398393@pytest .mark .parametrize (
399394 "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):
405400
406401 # no copy by default
407402 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" :
409404 assert np .shares_memory (arr , result ) is False
410405 else :
411406 assert np .shares_memory (arr , result ) is True
412407
413408 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" :
415410 assert np .shares_memory (arr , result ) is False
416411 else :
417412 assert np .shares_memory (arr , result ) is True
0 commit comments