joheinze/PriNCe

unit tests and/or test notebooks needed

Opened this issue · 3 comments

A few units test or test notebooks would be useful.

There were test notebooks in the old SVN repository under ./test, which were not migrated to git. While they need to be cleaned up and ported to Python 3, these could be useful to keep.

I converted all the test notebooks from the SVN repo (or rather only those that had meaningful content)

Be sure to only commit changes to these, if you have all the outputs
(These notebooks contain alot of plots)

I added a few unit tests, which run simple propagation cases.
These can still be impoved, the assertions now mainly check if the particle channels present are correct. Not the actual spectra.

Do you have an idea, how one would best assert, if the spectra are correctly propagated?

Also still needs integration with automatic testing

OK, so for the spectra I would compare the sum or so.
To avoid python version madness you may wanna do something use string formatted numbers and compare the strings. Somthing like:

def format_8_digits(a_list):
return ["%.8e" % member for member in a_list]

assert format_8_digits(nmu), ['5.62504370e-03', '4.20479234e-03', '1.36630552e-03', '8.20255259e-06']

Where the numbers are the expected results.

Automatic testing, correct. It is actually quite simple for a pure python code. Because one can build a python 3 wheel, that doesn't require building and testing on 20 architectures. To be honest I'm not super happy to drop python 2.7 support. I don't think that in general it will be a pain, but there are only a couple of features. I'm not at all insisting on that though.

To start setting this up, look at my crflux package. Create and adjust the .ci folder. As you can see the script is kinda generic, only requirements are important. If you build a wheel try to install it on a fresh conda env with the requirements txt and run the tests. How to set up Azure Pipelines is a bit more tedious I can walk you through on skype or follow:

https://iscinumpy.gitlab.io/post/azure-devops-python-wheels/

or https://github.com/scikit-hep/azure-wheel-helpers