-
Notifications
You must be signed in to change notification settings - Fork 588
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
Use biased_coin in FeatureFlags #2485
Conversation
This looks good to me in itself, but after starting at the code for a while I think we get the wrong distribution when |
I don't think this is true.
|
You're right, but in this case don't we need to write |
Hmm. You're right that it does. I thought it wasn't supposed to and it was always choosing the bit length large enough to avoid doing that. I'll add some tests and fix that. Thanks, good catch! |
…ve 1 as True and 0 as False
It wasn't doing that. Apparently it was reducing the bit length where it could but never raising it. I've now modified the implementation of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nice set of changes for clarity as well as performance 🙂
One comment below, but I don't need to review it again.
…ration isn't already <= 1
It looks like this made the shrink quality tests slightly flaky, so I added another patch to |
I was thinking that Final commit looks good, I'm a big fan of |
Oh, sure. Good idea. |
de2d98d
to
8f752f0
Compare
Looks like this breaks some tests, and this PR has scope creeped enough as it is, so I'm not going to do this now. |
I'll open an issue then, it's a nice small one for the SciPy sprint today 😄 |
Part of why #2483 was so fiddly was that it turns out that our feature flags implementation shrinks very badly. On the one hand this was good in that it revealed problems with the pass that it was useful to catch, on the other hand it'd be nicer if it just didn't shrink badly.
The problem is basically that it leaves high bytes in the choice sequence as an intrinsic feature, so the shrinker potentially has to do a lot of work repeatedly checking if it can lower those. Ideally all bytes would be 0 or 1 after a successful shrink. This is easy to achieve by swapping over the implementation to
biased_coin
, which already has optimisations for this.In order to enable this more elegantly this caused me to add a feature to
biased_coin
which allows you to force the value it returns. Once I'd done that it made sense to make use of that in themany
utils class which essentially faked that feature badly on its own.