Contribute Media
A thank you to everyone who makes this possible: Read More

Hands On Introduction to Property Based Testing for Science

Description

Code is now a critical part of almost all research, whether for communication or for data collection and analysis. Unfortunately, producing reliably error-free code is an open problem, and result-altering bugs are regularly found (and usually fixed) in everything from preprints to foundational open source packages. I believe there is a core, fixable problem: writing tests is tedious, difficult, and only covers edge cases we know to test for. The solution? Use tools that write tests for us! Crucially, this isn't a pipe-dream: it's a proven technique that the scipy ecosystem has already started to use, and just needs to scale up. Hypothesis - https://hypothesis.readthedocs.io/ - is basically a superhuman experimentalist. You write a test function and describe what inputs it should pass for; and the Hypothesis engine searches for a falsifying example. This process often tries inputs that I wouldn't think of, such as Numpy arrays with a sizezero dimension or a "signalling" NaN represented by a non-standard bit-pattern; and as a result it regularly uncovers bugs that users and authors didn't know were possible. The Tutorial is designed for researchers and software engineers who regularly write code that other scientists rely on. You might be 'the Python person' in your lab; a core developer of one of the core SciPy or PyData libraries, or an enthusiast looking for a valuable way to contribute to that ecosystem. Attendees are expected to be familiar with Numpy and Pandas, as well as with traditional unit testing (i.e. pytest or unittest), and ideally with writing traditional tests for numerical or data-centric code. You don't need to be an expert in any of these, but the Tutorial will have plenty of content to engage those who are! If this sounds too good to be true, Hypothesis has quickly found bugs in approximately everything it has even been pointed at, including Numpy, Astropy, Xarray, CPython, and of course Hypothesis itself. If you already have a large stack of bug reports, maybe ask that it only be used for new features!

Details

Improve this page