Skip to content

Commit 417c254

Browse files
authored
Revert "TST: Filter/test pyarrow PerformanceWarnings (#48093)"
This reverts commit 786c28f.
1 parent 5cbbc2c commit 417c254

File tree

3 files changed

+11
-185
lines changed

3 files changed

+11
-185
lines changed

pandas/tests/base/test_value_counts.py

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
import numpy as np
55
import pytest
66

7-
from pandas.compat import pa_version_under7p0
8-
from pandas.errors import PerformanceWarning
9-
107
import pandas as pd
118
from pandas import (
129
DatetimeIndex,
@@ -39,16 +36,8 @@ def test_value_counts(index_or_series_obj):
3936
# TODO(GH#32514): Order of entries with the same count is inconsistent
4037
# on CI (gh-32449)
4138
if obj.duplicated().any():
42-
with tm.maybe_produces_warning(
43-
PerformanceWarning,
44-
pa_version_under7p0 and getattr(obj.dtype, "storage", "") == "pyarrow",
45-
):
46-
result = result.sort_index()
47-
with tm.maybe_produces_warning(
48-
PerformanceWarning,
49-
pa_version_under7p0 and getattr(obj.dtype, "storage", "") == "pyarrow",
50-
):
51-
expected = expected.sort_index()
39+
result = result.sort_index()
40+
expected = expected.sort_index()
5241
tm.assert_series_equal(result, expected)
5342

5443

@@ -81,16 +70,8 @@ def test_value_counts_null(null_obj, index_or_series_obj):
8170
if obj.duplicated().any():
8271
# TODO(GH#32514):
8372
# Order of entries with the same count is inconsistent on CI (gh-32449)
84-
with tm.maybe_produces_warning(
85-
PerformanceWarning,
86-
pa_version_under7p0 and getattr(obj.dtype, "storage", "") == "pyarrow",
87-
):
88-
expected = expected.sort_index()
89-
with tm.maybe_produces_warning(
90-
PerformanceWarning,
91-
pa_version_under7p0 and getattr(obj.dtype, "storage", "") == "pyarrow",
92-
):
93-
result = result.sort_index()
73+
expected = expected.sort_index()
74+
result = result.sort_index()
9475

9576
if not isinstance(result.dtype, np.dtype):
9677
# i.e IntegerDtype
@@ -103,16 +84,8 @@ def test_value_counts_null(null_obj, index_or_series_obj):
10384
if obj.duplicated().any():
10485
# TODO(GH#32514):
10586
# Order of entries with the same count is inconsistent on CI (gh-32449)
106-
with tm.maybe_produces_warning(
107-
PerformanceWarning,
108-
pa_version_under7p0 and getattr(obj.dtype, "storage", "") == "pyarrow",
109-
):
110-
expected = expected.sort_index()
111-
with tm.maybe_produces_warning(
112-
PerformanceWarning,
113-
pa_version_under7p0 and getattr(obj.dtype, "storage", "") == "pyarrow",
114-
):
115-
result = result.sort_index()
87+
expected = expected.sort_index()
88+
result = result.sort_index()
11689
tm.assert_series_equal(result, expected)
11790

11891

pandas/tests/extension/test_string.py

Lines changed: 3 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
import numpy as np
1919
import pytest
2020

21-
from pandas.compat import (
22-
pa_version_under6p0,
23-
pa_version_under7p0,
24-
)
21+
from pandas.compat import pa_version_under6p0
2522
from pandas.errors import PerformanceWarning
2623

2724
import pandas as pd
@@ -170,22 +167,6 @@ def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna):
170167

171168

172169
class TestMethods(base.BaseMethodsTests):
173-
def test_argsort(self, data_for_sorting):
174-
with tm.maybe_produces_warning(
175-
PerformanceWarning,
176-
pa_version_under7p0
177-
and getattr(data_for_sorting.dtype, "storage", "") == "pyarrow",
178-
):
179-
super().test_argsort(data_for_sorting)
180-
181-
def test_argsort_missing(self, data_missing_for_sorting):
182-
with tm.maybe_produces_warning(
183-
PerformanceWarning,
184-
pa_version_under7p0
185-
and getattr(data_missing_for_sorting.dtype, "storage", "") == "pyarrow",
186-
):
187-
super().test_argsort_missing(data_missing_for_sorting)
188-
189170
def test_argmin_argmax(
190171
self, data_for_sorting, data_missing_for_sorting, na_value, request
191172
):
@@ -229,89 +210,6 @@ def test_argreduce_series(
229210
data_missing_for_sorting, op_name, skipna, expected
230211
)
231212

232-
@pytest.mark.parametrize("dropna", [True, False])
233-
def test_value_counts(self, all_data, dropna, request):
234-
all_data = all_data[:10]
235-
if dropna:
236-
other = all_data[~all_data.isna()]
237-
else:
238-
other = all_data
239-
with tm.maybe_produces_warning(
240-
PerformanceWarning,
241-
pa_version_under7p0
242-
and getattr(all_data.dtype, "storage", "") == "pyarrow"
243-
and not (dropna and "data_missing" in request.node.nodeid),
244-
):
245-
result = pd.Series(all_data).value_counts(dropna=dropna).sort_index()
246-
with tm.maybe_produces_warning(
247-
PerformanceWarning,
248-
pa_version_under7p0
249-
and getattr(other.dtype, "storage", "") == "pyarrow"
250-
and not (dropna and "data_missing" in request.node.nodeid),
251-
):
252-
expected = pd.Series(other).value_counts(dropna=dropna).sort_index()
253-
254-
self.assert_series_equal(result, expected)
255-
256-
@pytest.mark.filterwarnings("ignore:Falling back:pandas.errors.PerformanceWarning")
257-
def test_value_counts_with_normalize(self, data):
258-
super().test_value_counts_with_normalize(data)
259-
260-
def test_argsort_missing_array(self, data_missing_for_sorting):
261-
with tm.maybe_produces_warning(
262-
PerformanceWarning,
263-
pa_version_under7p0
264-
and getattr(data_missing_for_sorting.dtype, "storage", "") == "pyarrow",
265-
):
266-
super().test_argsort_missing(data_missing_for_sorting)
267-
268-
@pytest.mark.parametrize(
269-
"na_position, expected",
270-
[
271-
("last", np.array([2, 0, 1], dtype=np.dtype("intp"))),
272-
("first", np.array([1, 2, 0], dtype=np.dtype("intp"))),
273-
],
274-
)
275-
def test_nargsort(self, data_missing_for_sorting, na_position, expected):
276-
# GH 25439
277-
with tm.maybe_produces_warning(
278-
PerformanceWarning,
279-
pa_version_under7p0
280-
and getattr(data_missing_for_sorting.dtype, "storage", "") == "pyarrow",
281-
):
282-
super().test_nargsort(data_missing_for_sorting, na_position, expected)
283-
284-
@pytest.mark.parametrize("ascending", [True, False])
285-
def test_sort_values(self, data_for_sorting, ascending, sort_by_key):
286-
with tm.maybe_produces_warning(
287-
PerformanceWarning,
288-
pa_version_under7p0
289-
and getattr(data_for_sorting.dtype, "storage", "") == "pyarrow",
290-
):
291-
super().test_sort_values(data_for_sorting, ascending, sort_by_key)
292-
293-
@pytest.mark.parametrize("ascending", [True, False])
294-
def test_sort_values_missing(
295-
self, data_missing_for_sorting, ascending, sort_by_key
296-
):
297-
with tm.maybe_produces_warning(
298-
PerformanceWarning,
299-
pa_version_under7p0
300-
and getattr(data_missing_for_sorting.dtype, "storage", "") == "pyarrow",
301-
):
302-
super().test_sort_values_missing(
303-
data_missing_for_sorting, ascending, sort_by_key
304-
)
305-
306-
@pytest.mark.parametrize("ascending", [True, False])
307-
def test_sort_values_frame(self, data_for_sorting, ascending):
308-
with tm.maybe_produces_warning(
309-
PerformanceWarning,
310-
pa_version_under7p0
311-
and getattr(data_for_sorting.dtype, "storage", "") == "pyarrow",
312-
):
313-
super().test_sort_values_frame(data_for_sorting, ascending)
314-
315213

316214
class TestCasting(base.BaseCastingTests):
317215
pass
@@ -338,41 +236,8 @@ class TestPrinting(base.BasePrintingTests):
338236

339237

340238
class TestGroupBy(base.BaseGroupbyTests):
341-
@pytest.mark.parametrize("as_index", [True, False])
342-
def test_groupby_extension_agg(self, as_index, data_for_grouping):
343-
df = pd.DataFrame({"A": [1, 1, 2, 2, 3, 3, 1, 4], "B": data_for_grouping})
344-
with tm.maybe_produces_warning(
345-
PerformanceWarning,
346-
pa_version_under7p0
347-
and getattr(data_for_grouping.dtype, "storage", "") == "pyarrow",
348-
):
349-
result = df.groupby("B", as_index=as_index).A.mean()
350-
with tm.maybe_produces_warning(
351-
PerformanceWarning,
352-
pa_version_under7p0
353-
and getattr(data_for_grouping.dtype, "storage", "") == "pyarrow",
354-
):
355-
_, uniques = pd.factorize(data_for_grouping, sort=True)
356-
357-
if as_index:
358-
index = pd.Index._with_infer(uniques, name="B")
359-
expected = pd.Series([3.0, 1.0, 4.0], index=index, name="A")
360-
self.assert_series_equal(result, expected)
361-
else:
362-
expected = pd.DataFrame({"B": uniques, "A": [3.0, 1.0, 4.0]})
363-
self.assert_frame_equal(result, expected)
364-
365-
def test_groupby_extension_transform(self, data_for_grouping):
366-
with tm.maybe_produces_warning(
367-
PerformanceWarning,
368-
pa_version_under7p0
369-
and getattr(data_for_grouping.dtype, "storage", "") == "pyarrow",
370-
):
371-
super().test_groupby_extension_transform(data_for_grouping)
372-
373-
@pytest.mark.filterwarnings("ignore:Falling back:pandas.errors.PerformanceWarning")
374-
def test_groupby_extension_apply(self, data_for_grouping, groupby_apply_op):
375-
super().test_groupby_extension_apply(data_for_grouping, groupby_apply_op)
239+
def test_groupby_extension_transform(self, data_for_grouping, request):
240+
super().test_groupby_extension_transform(data_for_grouping)
376241

377242

378243
class Test2DCompat(base.Dim2CompatTests):

pandas/tests/test_algos.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
algos as libalgos,
1010
hashtable as ht,
1111
)
12-
from pandas.compat import pa_version_under7p0
13-
from pandas.errors import PerformanceWarning
1412
import pandas.util._test_decorators as td
1513

1614
from pandas.core.dtypes.common import (
@@ -52,13 +50,7 @@ class TestFactorize:
5250
@pytest.mark.parametrize("sort", [True, False])
5351
def test_factorize(self, index_or_series_obj, sort):
5452
obj = index_or_series_obj
55-
with tm.maybe_produces_warning(
56-
PerformanceWarning,
57-
sort
58-
and pa_version_under7p0
59-
and getattr(obj.dtype, "storage", "") == "pyarrow",
60-
):
61-
result_codes, result_uniques = obj.factorize(sort=sort)
53+
result_codes, result_uniques = obj.factorize(sort=sort)
6254

6355
constructor = Index
6456
if isinstance(obj, MultiIndex):
@@ -72,11 +64,7 @@ def test_factorize(self, index_or_series_obj, sort):
7264
expected_uniques = expected_uniques.astype(object)
7365

7466
if sort:
75-
with tm.maybe_produces_warning(
76-
PerformanceWarning,
77-
pa_version_under7p0 and getattr(obj.dtype, "storage", "") == "pyarrow",
78-
):
79-
expected_uniques = expected_uniques.sort_values()
67+
expected_uniques = expected_uniques.sort_values()
8068

8169
# construct an integer ndarray so that
8270
# `expected_uniques.take(expected_codes)` is equal to `obj`

0 commit comments

Comments
 (0)