I am at the moment implementing PBB for Matlab and am somehow influenced by hypothesis.
I do not understand how hypothesis handles the shrinking of deferred strategies. In the documentation there is the code snippet
import hypothesis.strategies as st
x = st.deferred(lambda: st.booleans() | st.tuples(x, x))
x.example()
>>> (((False, (True, True)), (False, True)), (True, True))
Now, this example should most likely shrink by reducing the depth of recursion. But, how does hypothesis know how to manipulate the lambda such that the example gets shrunk?
Question after answer of DRMacIver:
- Is hypothesis storing which choices belong to which strategy? E.g.:
(False,(False,False))
can be constructed as10010000
(depth first). If we take the subsequence01
(where the first0
belongs to the strategybooleans
instead totuples
now) we would get the exampleTrue
, which probably does not count as a shrinked version of the former.