@@ -25,7 +25,11 @@ def test_contains(any_string_dtype):
2525 values = Series (values , dtype = any_string_dtype )
2626 pat = "mmm[_]+"
2727
28- result = values .str .contains (pat )
28+ with tm .maybe_produces_warning (
29+ PerformanceWarning ,
30+ any_string_dtype == "string[pyarrow]" and pa_version_under4p0 ,
31+ ):
32+ result = values .str .contains (pat )
2933 expected_dtype = "object" if any_string_dtype == "object" else "boolean"
3034 expected = Series (
3135 np .array ([False , np .nan , True , True , False ], dtype = np .object_ ),
@@ -88,7 +92,11 @@ def test_contains(any_string_dtype):
8892 )
8993 tm .assert_series_equal (result , expected )
9094
91- result = values .str .contains (pat , na = False )
95+ with tm .maybe_produces_warning (
96+ PerformanceWarning ,
97+ any_string_dtype == "string[pyarrow]" and pa_version_under4p0 ,
98+ ):
99+ result = values .str .contains (pat , na = False )
92100 expected_dtype = np .bool_ if any_string_dtype == "object" else "boolean"
93101 expected = Series (np .array ([False , False , True , True ]), dtype = expected_dtype )
94102 tm .assert_series_equal (result , expected )
@@ -181,7 +189,11 @@ def test_contains_moar(any_string_dtype):
181189 dtype = any_string_dtype ,
182190 )
183191
184- result = s .str .contains ("a" )
192+ with tm .maybe_produces_warning (
193+ PerformanceWarning ,
194+ any_string_dtype == "string[pyarrow]" and pa_version_under4p0 ,
195+ ):
196+ result = s .str .contains ("a" )
185197 expected_dtype = "object" if any_string_dtype == "object" else "boolean"
186198 expected = Series (
187199 [False , False , False , True , True , False , np .nan , False , False , True ],
@@ -619,7 +631,11 @@ def test_replace_moar(any_string_dtype):
619631 dtype = any_string_dtype ,
620632 )
621633
622- result = ser .str .replace ("A" , "YYY" )
634+ with tm .maybe_produces_warning (
635+ PerformanceWarning ,
636+ any_string_dtype == "string[pyarrow]" and pa_version_under4p0 ,
637+ ):
638+ result = ser .str .replace ("A" , "YYY" )
623639 expected = Series (
624640 ["YYY" , "B" , "C" , "YYYaba" , "Baca" , "" , np .nan , "CYYYBYYY" , "dog" , "cat" ],
625641 dtype = any_string_dtype ,
@@ -727,7 +743,11 @@ def test_replace_regex_single_character(regex, any_string_dtype):
727743 ):
728744 result = s .str .replace ("." , "a" , regex = regex )
729745 else :
730- result = s .str .replace ("." , "a" , regex = regex )
746+ with tm .maybe_produces_warning (
747+ PerformanceWarning ,
748+ any_string_dtype == "string[pyarrow]" and pa_version_under4p0 ,
749+ ):
750+ result = s .str .replace ("." , "a" , regex = regex )
731751
732752 expected = Series (["aab" , "a" , "b" , np .nan , "" ], dtype = any_string_dtype )
733753 tm .assert_series_equal (result , expected )
0 commit comments