Hi Oscar and (all) I'm definitely excited to be working a the intersection of Hypothesis and Sympy! Looking to receiving input in the future.
Diane On Tuesday, July 18, 2023 at 6:32:31 PM UTC-4 Oscar wrote: > Hi Diane and welcome, > > I'm looking forward to seeing hypothesis used with SymPy. It seems > like it could be really useful and I looked at it a few times but I > just couldn't quite get my head round what the workflow would be, like > exactly how we could use it... > > If you can figure that out (and explain it to everyone) then I am sure > that we can put it to good use! > > Oscar > > On Wed, 5 Jul 2023 at 17:36, Aaron Meurer <[email protected]> wrote: > > > > Hi everyone. > > > > As many of you may know, I work at Quansight, a company that works > > with and funds a lot of open source work in the Python ecosystem. > > Quansight Labs has a yearly internship program where interns work on > > various open source projects. > > > > I'm happy to announce that this summer, Diane Tchuindjo will be > > interning at Quansight Labs to work on SymPy. Her project will be to > > introduce Hypothesis into the SymPy test suite. Everyone join me in > > welcoming Diane to the project. > > > > You can read more about the project here > > https://github.com/sympy/sympy/issues/20914. Basically, hypothesis > > (https://hypothesis.readthedocs.io/en/latest/) is a Python testing > > library that uses property based tests. This lets you write tests that > > take generic inputs and test functions using exact mathematical > > properties, rather than only testing explicit inputs and outputs. For > > example, to take an example from the issue, a Hypothesis test for > > factorint() might look like > > > > from hypothesis import given > > from hypothesis.strategies import integers > > > > @given(integers()) > > def test_factorint(x): > > f = factorint(x) > > assert Mul(*[b**e for b, e in f.items()]) == x > > for b in f: > > assert abs(b) in [0, 1] or isprime(b) > > > > (as opposed to the existing factorint tests, which just test explicit > > inputs and outputs > > > https://github.com/sympy/sympy/blob/master/sympy/ntheory/tests/test_factor_.py#L168 > ). > > This test generates an integer, runs factorint() on it, and tests that > > the result is mathematically correct (i.e., that the factors are prime > > and multiply back together to the original integer). > > > > This is somewhat like random testing, except Hypothesis is actually a > > lot more sophisticated than a purely random test, because it always > > tries to generate interesting examples, and it also does things like > > shrinking test inputs, and makes input strategies easy to compose. In > > my experience, Hypothesis is *really* good at finding bugs that you > > would otherwise never find. > > > > Hypothesis has always been a good fit for SymPy, but we've as of yet > > never used it. Our plan is to start small, to prove its usefulness, > > but I'm confident we will be able to convince the SymPy community that > > Hypothesis is a tool that we should be using regularly in the SymPy > > test suite. > > > > Aaron Meurer > > > > -- > > You received this message because you are subscribed to the Google > Groups "sympy" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/CAKgW%3D6Js_3keq-UcmRQDaVtu2mhagBgVauTBpS%3DKyO4vYSWQ3A%40mail.gmail.com > . > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/0b0a5549-7e2b-40ac-ba77-f91ad68628c8n%40googlegroups.com.
