HealthCheck/Unsatisfiable errors with newer version

27 views
Skip to first unread message

Hugh Hopper

unread,
Aug 17, 2022, 8:00:35 AM8/17/22
to Hypothesis users
hi,

I have some tests using the arrays strategy. These were working fine with the old version of hypothesis i had, but I upgraded to the latest version and it causes HealthCheck failures. I added a suppress_health_check setting, to see if the test would at least run, and it still cant run due to an Unsatisfiable error.

basic minimum example looks like this:
import numpy as np
from hypothesis import settings, HealthCheck, given, strategies as st
from hypothesis.extra.numpy import arrays as st_arrays

@given(st_arrays(np.float64, (2, 257), elements=st.floats(np.finfo(float).eps, 1e6), unique=True))
@settings(suppress_health_check=HealthCheck.all(), max_examples=5)
def test_array_strat(x):
    assert type(x) is np.ndarray


the weird thing is that if i downgrade to hypothesis==6.10.0 it runs without issue. with 6.54.3 is where i get these errors. I cant see any difference in the calls to the array or float strategy. Am I missing something? What is going on here?

thanks,

hugh

Zac Hatfield Dodds

unread,
Aug 20, 2022, 5:01:37 AM8/20/22
to Hugh Hopper, Hypothesis users
Hi Hugh

The problem in this case is that your shape `(2, 257)` is quite a few elements for Hypothesis to try to generate, and so we run over the maximum allowed entropy and fail to generate anything.  The error message for this isn't great with healthchecks disabled, but if you comment out the settings you'd see:

> hypothesis.errors.FailedHealthCheck: Data generation is extremely slow: Only produced 0 valid examples in 1.04 seconds (5 invalid ones and 19 exceeded maximum size). Try decreasing size of the data you're generating (with e.g. max_size or max_leaves parameters).

This probably changed because the fixes in https://hypothesis.readthedocs.io/en/latest/changes.html#v6-46-8 made Hypothesis better at finding bugs with floating-point numbers, but at the expense of consuming slightly more entropy to do so.

TLDR: you can fix this by using a much smaller array shape for unique arrays, which is faster and equally good for finding most bugs.

Best,
Zac


--
You received this message because you are subscribed to the Google Groups "Hypothesis users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hypothesis-use...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/hypothesis-users/bdd811fb-4b0c-450e-8e4c-f90ab12094dfn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages