@@ -25,7 +25,11 @@ def test_contains(any_string_dtype):
25
25
values = Series (values , dtype = any_string_dtype )
26
26
pat = "mmm[_]+"
27
27
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 )
29
33
expected_dtype = "object" if any_string_dtype == "object" else "boolean"
30
34
expected = Series (
31
35
np .array ([False , np .nan , True , True , False ], dtype = np .object_ ),
@@ -88,7 +92,11 @@ def test_contains(any_string_dtype):
88
92
)
89
93
tm .assert_series_equal (result , expected )
90
94
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 )
92
100
expected_dtype = np .bool_ if any_string_dtype == "object" else "boolean"
93
101
expected = Series (np .array ([False , False , True , True ]), dtype = expected_dtype )
94
102
tm .assert_series_equal (result , expected )
@@ -181,7 +189,11 @@ def test_contains_moar(any_string_dtype):
181
189
dtype = any_string_dtype ,
182
190
)
183
191
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" )
185
197
expected_dtype = "object" if any_string_dtype == "object" else "boolean"
186
198
expected = Series (
187
199
[False , False , False , True , True , False , np .nan , False , False , True ],
@@ -619,7 +631,11 @@ def test_replace_moar(any_string_dtype):
619
631
dtype = any_string_dtype ,
620
632
)
621
633
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" )
623
639
expected = Series (
624
640
["YYY" , "B" , "C" , "YYYaba" , "Baca" , "" , np .nan , "CYYYBYYY" , "dog" , "cat" ],
625
641
dtype = any_string_dtype ,
@@ -727,7 +743,11 @@ def test_replace_regex_single_character(regex, any_string_dtype):
727
743
):
728
744
result = s .str .replace ("." , "a" , regex = regex )
729
745
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 )
731
751
732
752
expected = Series (["aab" , "a" , "b" , np .nan , "" ], dtype = any_string_dtype )
733
753
tm .assert_series_equal (result , expected )
0 commit comments