Luke Lee

Software Engineer

Web + Desktop + Science

Fork me on Github

Using diff and pickles for unit testing

I stressed using diff and serialized numpy arrays in my recent talk on testing. I was pleasantly surprised to read the authors of High Performance Python agree.

Unit testing a complicated section of code that generates a large numerical output may be difficult. Do not be afraid to output a text file of results to run through diff or to use a pickled object. For numeric optimization problems, Ian likes to create long text files of floating-point numbers and use diff—minor rounding errors show up immediately, even if they’re rare in the output.

By the way, go and read High Performance Python. It's excellent.

Published: 11-05-2014 00:27:21

lukelee.net