Skip to content

TST: tweak Hypothesis configuration and idioms #23441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
hypothesis.settings.register_profile(
"ci",
# Hypothesis timing checks are tuned for scalars by default, so we bump
# them from 200ms to 5 secs per test case as the global default. If this
# 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(timeout=...)` with a working value.
timeout=5000,
# if it really is slow add `@settings(deadline=...)` with a working value,
# or `deadline=None` to entirely disable timeouts for that test.
deadline=500,
timeout=hypothesis.unlimited,
suppress_health_check=(hypothesis.HealthCheck.too_slow,)
)
hypothesis.settings.load_profile("ci")
Expand Down
29 changes: 15 additions & 14 deletions pandas/tests/frame/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,20 @@ def zip_frames(frames, axis=1):
return pd.DataFrame(zipped)


@composite
def indices(draw, max_length=5):
date = draw(
dates(
min_value=Timestamp.min.ceil("D").to_pydatetime().date(),
max_value=Timestamp.max.floor("D").to_pydatetime().date(),
).map(Timestamp)
)
periods = draw(integers(0, max_length))
freq = draw(sampled_from(list("BDHTS")))
dr = date_range(date, periods=periods, freq=freq)
return pd.DatetimeIndex(list(dr))


class TestDataFrameAggregate():

def test_agg_transform(self, axis, float_frame):
Expand Down Expand Up @@ -1142,20 +1156,7 @@ def test_agg_cython_table_raises(self, df, func, expected, axis):
with pytest.raises(expected):
df.agg(func, axis=axis)

@composite
def indices(draw, max_length=5):
date = draw(
dates(
min_value=Timestamp.min.ceil("D").to_pydatetime().date(),
max_value=Timestamp.max.floor("D").to_pydatetime().date(),
).map(Timestamp)
)
periods = draw(integers(0, max_length))
freq = draw(sampled_from(list("BDHTS")))
dr = date_range(date, periods=periods, freq=freq)
return pd.DatetimeIndex(list(dr))

@given(index=indices(5), num_columns=integers(0, 5))
@given(index=indices(max_length=5), num_columns=integers(0, 5))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, we would prefer that separate changes go into separate PR's, but these are small enough that it should be okay.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kinda related in that this is input to the test that was timing out, but point taken - I'll try to split future changes like this into multiple PRs 😄

def test_frequency_is_original(self, index, num_columns):
# GH 22150
original = index.copy()
Expand Down