-
Notifications
You must be signed in to change notification settings - Fork 594
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
Hypothesis shrinking doesn't find minimal example #1857
Comments
I've recently (#1790) written up a guide to shrinking - here's the current version. You can skip the internals section at the end, but I think the rest is worth reading. Specifically:
Hope that helps 😄 (closing the issue as I don't think there's any action we need to take in Hypothesis itself) |
I've been thinking about the possibility of adding a “filtered sampling” strategy that allows end-users to use shrink-open techniques in a controlled and user-friendly way. For suitable strategies, this should give better results than current post-filtering or ad-hoc approaches. However, I can open a dedicated issue or PR once I've had a chance to experiment with this idea. |
I actually asked @boustrophedon to file this, as I thought it was a nice example and it's a shame that it doesn't work out of the box. I don't think it's high priority, and the right thing to do on @boustrophedon's end probably is to change the implementation, but I think it'd be worth investigating what's going on here because it might point to something interesting. |
I like this idea a lot FWIW. |
@DRMacIver - I think a general solution to this would be to run something like the block programs over examples at each depth - deleting two adjacent rule calls ( |
As I mentioned in IRC, I had a dumb idea: Use hypothesis stateful testing to solve the towers of Hanoi problem.
It actually works:
but 9 moves is not minimal (it takes 2^n-1 moves for n rings). You can see that in draws 6 and 7 it just shuffles one ring back and forth.
In other runs, it does find a minimal example.
Full repro here: https://gist.github.com/boustrophedon/a0905a18ef45dea4a5b36b6cead54222
Also, I was wondering if there's a better way to structure this (maybe with the composite decorator?) such that instead of printing the draws it could just print
move(0,1)
somehow. There's a hook to print something extra on the line when youdata.draw
, so maybe I could implement aprinter
parameter for draw that takes a function with the results of the draw as input and prints it out/returns a string?The text was updated successfully, but these errors were encountered: