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
Utilizing Hypothesis in the ntheory/polys directory #25428
Conversation
✅ Hi, I am the SymPy bot (v170). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.
Click here to see the pull request description that was parsed.
|
🟠Hi, I am the SymPy bot (v170). I've noticed that some of your commits add or delete files. Since this is sometimes done unintentionally, I wanted to alert you about it. This is an experimental feature of SymPy Bot. If you have any feedback on it, please comment at sympy/sympy-bot#75. The following commits add new files:
The following commits delete files:
If these files were added/deleted on purpose, you can ignore this message. |
CC @honno |
Hi @dianetc thanks for this pull request! I left a few comments on the tests. I'd also like for @honno to review this as well. We need to make sure we add hypothesis to the CI here before this can be merged (by installing Note to everyone that hypothesis will just be added as a testing dependency only, not a runtime dependency. I personally feel like it should be a required testing dependency, but if people feel strongly about it we can make it an optional dependency instead. |
Currently the CI fails because running Pyodide doesn't support Hypothesis , so it seems there may be two options (?):
I'm not too sure if option number 2 will work. Moreover, it seems to undermine the whole point of that test. |
It looks like one of the tests failed with
|
The reported flakiness could be investigated, but it's likely due to certain things being cached. That sort of thing is quite common in SymPy, unfortunately, meaning these timing flakiness checks are not going to be very helpful. Is there a way to disable timing flakiness checks without also disabling the deadline entirely? |
Don't think so 🙃 Note @dianetc you can apply from hypothesis import settings
settings.register_profile("no_deadline", deadline=None)
settings.load_profile("no_deadline") |
Benchmark results from GitHub Actions Lower numbers are good, higher numbers are bad. A ratio less than 1 Significantly changed benchmark results (PR vs master) Significantly changed benchmark results (master vs previous release) before after ratio
[8059df73] [db5ca227]
<sympy-1.12^0>
- 84.6±0.8ms 55.9±0.3ms 0.66 integrate.TimeIntegrationRisch02.time_doit(10)
- 84.3±0.9ms 54.9±0.4ms 0.65 integrate.TimeIntegrationRisch02.time_doit_risch(10)
- 2.11±0.01ms 631±2μs 0.30 polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'sparse')
- 10.5±0.04ms 1.88±0.01ms 0.18 polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'sparse')
- 363±0.6μs 78.9±0.5μs 0.22 polys.TimePREM_QuadraticNonMonicGCD.time_op(1, 'sparse')
- 4.78±0.01ms 351±1μs 0.07 polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'sparse')
- 10.6±0.03ms 1.06±0ms 0.10 polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'sparse')
- 6.25±0.02ms 3.85±0.01ms 0.62 polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(2, 'sparse')
- 27.5±0.05ms 11.7±0.03ms 0.42 polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'sparse')
- 6.72±0.02ms 1.13±0.01ms 0.17 polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(1, 'sparse')
- 15.7±0.03ms 8.99±0.02ms 0.57 polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(2, 'sparse')
- 206±0.3ms 68.9±0.09ms 0.33 polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'sparse')
- 6.39±0.01ms 511±2μs 0.08 polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'sparse')
- 27.4±0.03ms 816±2μs 0.03 polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'sparse')
- 591±2μs 202±0.7μs 0.34 polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(1, 'sparse')
- 6.38±0ms 207±1μs 0.03 polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'sparse')
- 16.7±0.06ms 209±0.6μs 0.01 polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'sparse')
Full benchmark results can be found as artifacts in GitHub Actions |
It looks like the remaining things to do here are:
|
Going to merge this now. We can add more tests in later PRs. In the future, we'll want to expand the hypothesis documentation in the tests docs, especially once we start adding custom strategies. For now, I'm hopeful that this is enough that other people can start playing around with hypothesis tests as well. |
It might be worth putting out an announcement somewhere about this change:
Also the guide here should be corrected and hypothesis made more prominent:
|
When I say that the guide should be corrected I don't just mean in relation to hypothesis. It is also outdated in its information about pytest although I'm not sure if pytest is now a hard dependency (CC @brocksam). Also it is probably not worth mentioning cloudpickle at all here. |
The point of that dependencies page is to list every optional dependency of SymPy, because there are so many of them it's useful to have that information gathered into one place. That's why cloudpickle is listed there. It really isn't supposed to be just about the important ones. The other contributor guide pages are really where we should be emphasizing that pytest and hypothesis are development dependencies. |
Cloudpickle is just an optional dependency like the rest in the bigger list of optional dependencies. The section on running the tests should clearly state that both pytest and hypothesis are hard requirements to be able to run the tests (if that is true). Also since this page is for contributors the hard requirements just to be able to run the tests should be listed higher up by the hard runtime dependency mpmath rather than below the optional dependencies (most of which are often not needed at all). |
References to other Issues or PRs
In service to #20914, which seeks to introduce Hypothesis, a property based testing library, to the testing suite of Sympy.
Brief description of what is fixed or changed
This PR seeks to introduce Hypothesis to Sympy. Here various properties of certain functions are tested via Hypothesis. Namely,$\tau , \varphi $ (totient), and gcd. Certain properties of polynomial division are also tested.
The goal is for Hypothesis to be a testing dependency not a runtime dependency.
Other comments
Before this can pass, Hypothesis will need to be added to the CI.
Release Notes
NO ENTRY