-
Notifications
You must be signed in to change notification settings - Fork 587
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
Getting more people to work on the shrinker #1093
Comments
Since you encouraged questions... I'm having a little trouble following the If I delete the More details: For test files under the Here's what I'm running (in the root of the
Here it is with its output:
The example above is meant to be minimal-ish, but I first experienced this running
|
Hmm. Does it work inside the directory tree if you run with I've never noticed this as a problem, and that's probably because I always run locally with |
Works great with I've also confirmed that even outside the hypothesis directory tree, I've opened #1122 to suggest |
Removed |
@DRMacIver is the "paper about Hypothesis's test case reduction/shrinking" available to the public? Very interested in reading that! |
Closing this as we now have decent development guides, far better internal commenting, and a growing pool of people who have contributed to the Conjecture engine. Child issues tagged |
@Zac-HD @DRMacIver I've been looking at porting hypothesis to emacs lisp, so I've been trying to understand the internals of Hypothesis (rather than just being a contented user). The docs that exist are excellent and clear, but I've still found a few things unclear.
I hope this feedback is useful. I think I understand most of the API, but if you have a minute, it's not clear to me:
class WideRangeIntStrategy(IntStrategy):
distribution = d.Sampler([
4.0, 8.0, 1.0, 1.0, 0.5
])
sizes = [8, 16, 32, 64, 128] or these values: NASTY_FLOATS = sorted([
0.0, 0.5, 1.1, 1.5, 1.9, 1.0 / 3, 10e6, 10e-6, 1.175494351e-38,
2.2250738585072014e-308,
1.7976931348623157e+308, 3.402823466e+38, 9007199254740992, 1 - 10e-6,
2 + 10e-6, 1.192092896e-07, 2.2204460492503131e-016,
] + [float('inf'), float('nan')] * 5, key=flt.float_to_lex) |
Just some quick comments from me; David might (should?) know more 😄 To date we've tried to keep user and developer docs separate, to help reinforce the distinction between public interface and internals and that you don't need to understand the latter to use the former.
Blocks and examples are discussed in #1601 - hopefully that helps. My understanding is that the magic values are chosen quite arbitrarily based on the kinds of values that tend to expose bugs, or to give generally desirable size/complexity properties of generated data. I don't know exactly how they were chosen though, or whether we've evaluated alternatives. |
Calling Freezing is a one-way process. There is no The main difference between This makes them useful for different kinds of shrinker passes. Blocks get used by passes that want to treat a region of bytes as a number and reduce that number, whereas examples get used by passes that want to attempt “higher-level” transformations like deleting complicated list elements, or zeroing large regions of data in one go. The |
Having tried both approaches recently, I actually think The learning curve is a bit steep, but Python Conjecture isn't that complicated once you eventually get your bearings. And it's nice to be able to refer to the most mature and battle-tested implementation. |
Some of those floats exhibit classic gotchas inherent to floating point arithmetic. For example: >>> 9007199254740992.0
9007199254740992.0
>>> 9007199254740992.0 + 1.0
9007199254740992.0
>>> 9007199254740992.0 + 1.0 + 1.0
9007199254740992.0
>>> 9007199254740992.0 + 1.0 + 1.0 + 1.0 + 1.0 + 1.0
9007199254740992.0
>>> 9007199254740992.0 + 2.0
9007199254740994.0 Or of course: >>> from math import nan
>>> nan == nan
False Dunno if it's worth documenting this in the code, but those are some of the reasons they're "nasty". |
So having just finished my epic marathon of paper about Hypothesis's test case reduction/shrinking made a couple of things clear to me. Specifically:
(I am aware that my notions of fun are peculiar and that test-case reduction is my own specific obsession, but I think other people could easily come to share it given the first part).
THEREFORE, this is an outreach ticket to try and get more people to work on the shrinker.
I consider the following to be the success criteria for this ticket (but will allow for some goal post movement):
In aid of the above, I will be opening a large-ish number of shrink quality tickets and referencing them back here.
Note that the fun part is important. I wish to re-emphasise that at present there is literally no good reason to improve the Hypothesis shrinker except enjoyment and weird aesthetic obsessions: Due to the combination of better underlying model and a truly disproportionate amount of invested effort, it is currently so good that everyone else's shrinking looks comedically bad in comparison. This is a thing to work on because you think it would be fun much more than it is a thing to work on because you think it will be useful.
In aid of that, if you do want to work on this, please report back on anything that confuses or annoys you in the course of doing so. If you get stuck, please ask for help. These will be valuable contributions in their own right!
PS. If you end up wanting to work on this and are not on the Hypothesis core team, ask me for a copy of the paper about this, because it will clarify the underlying model. At some point I will be able to share it publicly but that point is not now.
The text was updated successfully, but these errors were encountered: