3232import numpy as np
3333import pytest
3434
35- from pandas ._config import using_pyarrow_strict_nans
36-
3735from pandas ._libs import lib
3836from pandas ._libs .tslibs import timezones
3937from pandas .compat import (
@@ -278,17 +276,14 @@ def test_compare_scalar(self, data, comparison_op):
278276 self ._compare_other (ser , data , comparison_op , data [0 ])
279277
280278 @pytest .mark .parametrize ("na_action" , [None , "ignore" ])
281- def test_map (self , data_missing , na_action ):
279+ def test_map (self , data_missing , na_action , using_nan_is_na ):
282280 if data_missing .dtype .kind in "mM" :
283281 result = data_missing .map (lambda x : x , na_action = na_action )
284282 expected = data_missing .to_numpy (dtype = object )
285283 tm .assert_numpy_array_equal (result , expected )
286284 else :
287285 result = data_missing .map (lambda x : x , na_action = na_action )
288- if (
289- data_missing .dtype == "float32[pyarrow]"
290- and not using_pyarrow_strict_nans ()
291- ):
286+ if data_missing .dtype == "float32[pyarrow]" and using_nan_is_na :
292287 # map roundtrips through objects, which converts to float64
293288 expected = data_missing .to_numpy (dtype = "float64" , na_value = np .nan )
294289 else :
@@ -705,7 +700,7 @@ def test_setitem_preserves_views(self, data):
705700
706701 @pytest .mark .parametrize ("dtype_backend" , ["pyarrow" , no_default ])
707702 @pytest .mark .parametrize ("engine" , ["c" , "python" ])
708- def test_EA_types (self , engine , data , dtype_backend , request ):
703+ def test_EA_types (self , engine , data , dtype_backend , request , using_nan_is_na ):
709704 pa_dtype = data .dtype .pyarrow_dtype
710705 if pa .types .is_decimal (pa_dtype ):
711706 request .applymarker (
@@ -726,7 +721,7 @@ def test_EA_types(self, engine, data, dtype_backend, request):
726721 pytest .mark .xfail (reason = "CSV parsers don't correctly handle binary" )
727722 )
728723 df = pd .DataFrame ({"with_dtype" : pd .Series (data , dtype = str (data .dtype ))})
729- if using_pyarrow_strict_nans () :
724+ if not using_nan_is_na :
730725 csv_output = df .to_csv (index = False , na_rep = "NA" )
731726 else :
732727 csv_output = df .to_csv (index = False , na_rep = np .nan )
@@ -1543,7 +1538,7 @@ def test_astype_errors_ignore():
15431538 tm .assert_frame_equal (result , expected )
15441539
15451540
1546- def test_to_numpy_with_defaults (data ):
1541+ def test_to_numpy_with_defaults (data , using_nan_is_na ):
15471542 # GH49973
15481543 result = data .to_numpy ()
15491544
@@ -1555,21 +1550,19 @@ def test_to_numpy_with_defaults(data):
15551550 else :
15561551 expected = np .array (data ._pa_array )
15571552
1558- if data ._hasna and (
1559- not is_numeric_dtype (data .dtype ) or using_pyarrow_strict_nans ()
1560- ):
1553+ if data ._hasna and (not is_numeric_dtype (data .dtype ) or not using_nan_is_na ):
15611554 expected = expected .astype (object )
15621555 expected [pd .isna (data )] = pd .NA
15631556
15641557 tm .assert_numpy_array_equal (result , expected )
15651558
15661559
1567- def test_to_numpy_int_with_na ():
1560+ def test_to_numpy_int_with_na (using_nan_is_na ):
15681561 # GH51227: ensure to_numpy does not convert int to float
15691562 data = [1 , None ]
15701563 arr = pd .array (data , dtype = "int64[pyarrow]" )
15711564 result = arr .to_numpy ()
1572- if using_pyarrow_strict_nans () :
1565+ if not using_nan_is_na :
15731566 expected = np .array ([1 , pd .NA ], dtype = object )
15741567 else :
15751568 expected = np .array ([1 , np .nan ])
@@ -3534,10 +3527,10 @@ def test_cast_dictionary_different_value_dtype(arrow_type):
35343527 assert result .dtypes .iloc [0 ] == data_type
35353528
35363529
3537- def test_map_numeric_na_action ():
3530+ def test_map_numeric_na_action (using_nan_is_na ):
35383531 ser = pd .Series ([32 , 40 , None ], dtype = "int64[pyarrow]" )
35393532 result = ser .map (lambda x : 42 , na_action = "ignore" )
3540- if using_pyarrow_strict_nans () :
3533+ if not using_nan_is_na :
35413534 expected = pd .Series ([42.0 , 42.0 , pd .NA ], dtype = "object" )
35423535 else :
35433536 expected = pd .Series ([42.0 , 42.0 , np .nan ], dtype = "float64" )
0 commit comments