From 4ee1065575549c127861dc3e69c524a6315f738a Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Sat, 18 Dec 2021 18:14:34 -0800 Subject: [PATCH 1/3] CI: Avoid flaky hypothesis test with deadline=None --- pandas/tests/frame/indexing/test_where.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/tests/frame/indexing/test_where.py b/pandas/tests/frame/indexing/test_where.py index a079a3a7921d7..5c401c1877f9b 100644 --- a/pandas/tests/frame/indexing/test_where.py +++ b/pandas/tests/frame/indexing/test_where.py @@ -2,6 +2,7 @@ from hypothesis import ( given, + settings, strategies as st, ) import numpy as np @@ -879,6 +880,7 @@ def test_where_nullable_invalid_na(frame_or_series, any_numeric_ea_dtype): OPTIONAL_DICTS, OPTIONAL_FLOATS, OPTIONAL_INTS, OPTIONAL_LISTS, OPTIONAL_TEXT ) ) +@settings(deadline=None) def test_where_inplace_casting(data): # GH 22051 df = DataFrame({"a": data}) From 39ef1d6d0318e6c3d69c682754e922914d110194 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Sat, 18 Dec 2021 18:15:45 -0800 Subject: [PATCH 2/3] Add issue ref --- pandas/tests/frame/indexing/test_where.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/frame/indexing/test_where.py b/pandas/tests/frame/indexing/test_where.py index 5c401c1877f9b..656a06afe9c28 100644 --- a/pandas/tests/frame/indexing/test_where.py +++ b/pandas/tests/frame/indexing/test_where.py @@ -880,7 +880,7 @@ def test_where_nullable_invalid_na(frame_or_series, any_numeric_ea_dtype): OPTIONAL_DICTS, OPTIONAL_FLOATS, OPTIONAL_INTS, OPTIONAL_LISTS, OPTIONAL_TEXT ) ) -@settings(deadline=None) +@settings(deadline=None) # GH 44969 def test_where_inplace_casting(data): # GH 22051 df = DataFrame({"a": data}) From f104cbdad16653b02b6f98d9b53bc9988e493e12 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Sun, 19 Dec 2021 15:04:39 -0800 Subject: [PATCH 3/3] Move set up to _hypothesis.py --- pandas/_testing/_hypothesis.py | 4 ++++ pandas/tests/frame/indexing/test_where.py | 15 ++------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/pandas/_testing/_hypothesis.py b/pandas/_testing/_hypothesis.py index 0e506f5e878b4..5256a303de34e 100644 --- a/pandas/_testing/_hypothesis.py +++ b/pandas/_testing/_hypothesis.py @@ -44,6 +44,10 @@ min_size=3, ) +OPTIONAL_ONE_OF_ALL = st.one_of( + OPTIONAL_DICTS, OPTIONAL_FLOATS, OPTIONAL_INTS, OPTIONAL_LISTS, OPTIONAL_TEXT +) + if is_platform_windows(): DATETIME_NO_TZ = st.datetimes(min_value=datetime(1900, 1, 1)) else: diff --git a/pandas/tests/frame/indexing/test_where.py b/pandas/tests/frame/indexing/test_where.py index 656a06afe9c28..e668e77644082 100644 --- a/pandas/tests/frame/indexing/test_where.py +++ b/pandas/tests/frame/indexing/test_where.py @@ -3,7 +3,6 @@ from hypothesis import ( given, settings, - strategies as st, ) import numpy as np import pytest @@ -23,13 +22,7 @@ isna, ) import pandas._testing as tm -from pandas._testing._hypothesis import ( - OPTIONAL_DICTS, - OPTIONAL_FLOATS, - OPTIONAL_INTS, - OPTIONAL_LISTS, - OPTIONAL_TEXT, -) +from pandas._testing._hypothesis import OPTIONAL_ONE_OF_ALL @pytest.fixture(params=["default", "float_string", "mixed_float", "mixed_int"]) @@ -875,11 +868,7 @@ def test_where_nullable_invalid_na(frame_or_series, any_numeric_ea_dtype): obj.mask(mask, null) -@given( - data=st.one_of( - OPTIONAL_DICTS, OPTIONAL_FLOATS, OPTIONAL_INTS, OPTIONAL_LISTS, OPTIONAL_TEXT - ) -) +@given(data=OPTIONAL_ONE_OF_ALL) @settings(deadline=None) # GH 44969 def test_where_inplace_casting(data): # GH 22051