-
Notifications
You must be signed in to change notification settings - Fork 616
Add chance to draw local constants in HypothesisProvider
#4356
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
Conversation
hypothesis-python/src/hypothesis/internal/conjecture/providers.py
Outdated
Show resolved
Hide resolved
Looks pretty sensible to me! Only design change I'd make - instead of passing |
crosshair failures (eg) from latest version. I added a crosshair version pin and corresponding task to update it Looking into the other actually-relevant failures on this branch |
Maybe we should split the probabilities for |
I've tracked down the pareto test failure to a potentially very old latent bug (manual front removal bypassing listeners) masked by our I think we should merge this knowing that the test is incorrect, and follow up in the next pull. I have a fix, but want to write a new test for it and make sure it's correct: diff --git i/hypothesis-python/src/hypothesis/internal/conjecture/pareto.py w/hypothesis-python/src/hypothesis/internal/conjecture/pareto.py
index 73f3e6a53..c282fa36e 100644
--- i/hypothesis-python/src/hypothesis/internal/conjecture/pareto.py
+++ w/hypothesis-python/src/hypothesis/internal/conjecture/pareto.py
@@ -248,7 +248,7 @@ class ParetoFront:
i -= 1
for v in to_remove:
- self.__remove(v)
+ self._remove(v)
return data in self.front
finally:
self.__pending = None
@@ -272,7 +272,7 @@ class ParetoFront:
def __len__(self) -> int:
return len(self.front)
- def __remove(self, data: ConjectureResult) -> None:
+ def _remove(self, data: ConjectureResult) -> None:
try:
self.front.remove(data)
except ValueError:
@@ -338,7 +338,7 @@ class ParetoOptimiser:
# the front, or it was not added to it because it was
# dominated by something in it.
try:
- self.front.front.remove(source)
+ self.front._remove(source)
except ValueError:
pass
return True |
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.
(one comment, will have more later in the week)
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.
Minor comments considering the sheer size of this PR. I eagerly anticipate the many new bugs this will uncover downstream... merge when addressed to your satisfaction.
crosshair-tool==0.0.85 | ||
hypothesis-crosshair==0.0.20 | ||
-c test.in # match test.in attrs pin |
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.
I have a bad feeling about these pins. Can we just list hypothesis-crosshair
(no pin) and -r test.in
, and then install from crosshair.txt
without test.txt
?
Also happy to merge this PR and follow up later.
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.
I'll follow up with this tomorrow, if only to unblock CI for other PRs!
hypothesis-python/src/hypothesis/internal/conjecture/providers.py
Outdated
Show resolved
Hide resolved
I'm happy with this PR from my end, but I'm about to sleep and there's no need to rush things. I'll merge tomorrow, or you're welcome to merge as well :) |
I'll be back with tests tomorrow, but figured it was worth PRing this for review.
An alternative to passing the local constants to
PrimitiveProvider
is to store it inBuildContext
. Downside: ConjectureData instance behavior is no longer isolated and depends on context; harder to test. Upside:PrimitiveProvider
implementers don't need to adjust their interface to access the constants, they can just opt-in to theBuildContext
.That said,
CrosshairProvider
usesdef __init__(self, *args, **kwargs)
, so this shouldn't actually be a breaking change for them.