From b0d916405faa88d757ab7b9ecd25483af8c483b8 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Sat, 2 Aug 2025 12:59:28 -0700 Subject: [PATCH 1/4] Avoid more work in larget_than_int32 tests --- pandas/tests/frame/test_stack_unstack.py | 5 ++++- pandas/tests/reshape/test_pivot.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pandas/tests/frame/test_stack_unstack.py b/pandas/tests/frame/test_stack_unstack.py index 22fdfd3a01408..3ff7483f30e05 100644 --- a/pandas/tests/frame/test_stack_unstack.py +++ b/pandas/tests/frame/test_stack_unstack.py @@ -2227,7 +2227,7 @@ def test_unstack_unobserved_keys(self, future_stack): tm.assert_frame_equal(recons, df) @pytest.mark.slow - def test_unstack_number_of_levels_larger_than_int32( + def test_unstack_number_of_levels_larger_than_int32_warns( self, performance_warning, monkeypatch ): # GH#20601 @@ -2239,6 +2239,9 @@ def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) raise Exception("Don't compute final result.") + def _make_selectors(self) -> None: + pass + with monkeypatch.context() as m: m.setattr(reshape_lib, "_Unstacker", MockUnstacker) df = DataFrame( diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index 2a58815c1cece..3aa79c4e4b517 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -2144,7 +2144,7 @@ def test_pivot_string_func_vs_func(self, f, f_numpy, data): tm.assert_frame_equal(result, expected) @pytest.mark.slow - def test_pivot_number_of_levels_larger_than_int32( + def test_pivot_number_of_levels_larger_than_int32_warns( self, performance_warning, monkeypatch ): # GH 20601 @@ -2155,6 +2155,9 @@ def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) raise Exception("Don't compute final result.") + def _make_selectors(self) -> None: + pass + with monkeypatch.context() as m: m.setattr(reshape_lib, "_Unstacker", MockUnstacker) df = DataFrame( From a613535c4bcbf7bff255c9c5ddec6c38c7077bff Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Sat, 2 Aug 2025 13:20:40 -0700 Subject: [PATCH 2/4] Refactor hypothesis profile --- pandas/conftest.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/pandas/conftest.py b/pandas/conftest.py index f9c10a7758bd2..51932480af2b3 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -176,23 +176,17 @@ def pytest_collection_modifyitems(items, config) -> None: ignore_doctest_warning(item, path, message) -hypothesis_health_checks = [ - hypothesis.HealthCheck.too_slow, - hypothesis.HealthCheck.differing_executors, -] - -# Hypothesis +# Similar to "ci" config in +# https://hypothesis.readthedocs.io/en/latest/reference/api.html#built-in-profiles hypothesis.settings.register_profile( "ci", - # Hypothesis timing checks are tuned for scalars by default, so we bump - # them from 200ms to 500ms per test case as the global default. If this - # is too short for a specific test, (a) try to make it faster, and (b) - # if it really is slow add `@settings(deadline=...)` with a working value, - # or `deadline=None` to entirely disable timeouts for that test. - # 2022-02-09: Changed deadline from 500 -> None. Deadline leads to - # non-actionable, flaky CI failures (# GH 24641, 44969, 45118, 44969) + database=None, deadline=None, - suppress_health_check=tuple(hypothesis_health_checks), + max_examples=25, + suppress_health_check=( + hypothesis.HealthCheck.too_slow, + hypothesis.HealthCheck.differing_executors, + ), ) hypothesis.settings.load_profile("ci") From 76ba985ccdaa7e5b6023bfbf57e1e815dbe67e28 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Sat, 2 Aug 2025 15:16:17 -0700 Subject: [PATCH 3/4] Limit more --- pandas/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/conftest.py b/pandas/conftest.py index 51932480af2b3..3b7a071142a02 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -182,7 +182,7 @@ def pytest_collection_modifyitems(items, config) -> None: "ci", database=None, deadline=None, - max_examples=25, + max_examples=15, suppress_health_check=( hypothesis.HealthCheck.too_slow, hypothesis.HealthCheck.differing_executors, From 8ca59bd9fe3a85facc61efd803436e8bfb79267a Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Sat, 2 Aug 2025 15:16:43 -0700 Subject: [PATCH 4/4] Rename profile too --- pandas/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/conftest.py b/pandas/conftest.py index 3b7a071142a02..a518b35755fad 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -179,7 +179,7 @@ def pytest_collection_modifyitems(items, config) -> None: # Similar to "ci" config in # https://hypothesis.readthedocs.io/en/latest/reference/api.html#built-in-profiles hypothesis.settings.register_profile( - "ci", + "pandas_ci", database=None, deadline=None, max_examples=15, @@ -188,7 +188,7 @@ def pytest_collection_modifyitems(items, config) -> None: hypothesis.HealthCheck.differing_executors, ), ) -hypothesis.settings.load_profile("ci") +hypothesis.settings.load_profile("pandas_ci") # Registering these strategies makes them globally available via st.from_type, # which is use for offsets in tests/tseries/offsets/test_offsets_properties.py