cta-observatory / dragonboard_testbench

Collection of programs to look at test data from the LST prototype camera.
1 stars 2 forks source link

Unit tests #23

Closed dneise closed 8 years ago

dneise commented 8 years ago

RunningStats is pure math and therefore nicely decoupled and nicely testable. I think it needs to be unit tested quickly.

Maybe this is a nice opportunity for people who have never written a unit test and would learn how this works...

The example below is one thing that should work but does not.

In [1]: import numpy as np

In [2]: from dragonboard.runningstats import RunningStats

In [3]: x = np.arange(1000).reshape(500, 2)

In [4]: rs = RunningStats(x[0].shape)

In [5]: for i in x:
    rs.add(i)
   ...:    

In [6]: rs.mean
Out[6]: array([ 499.,  500.])

In [7]: rs.std
Out[7]: array([ nan,  nan])
dneise commented 8 years ago

If you'd like to read up about Python unit testing, maybe this is a nice starting point:

MHoerbe commented 8 years ago

That*s cool stuff. Will get around to this in the future.

maxnoe commented 8 years ago

We should use py.test, as this is used by ctapipe.

There is an introduction on unit testing for cta here: https://github.com/cta-observatory/training-material/blob/master/tutorials/UnitTests.ipynb

maxnoe commented 8 years ago

I implemented two first unit tests in #25, we can add more. I will see that we also start using travis for this project.

maxnoe commented 8 years ago

Travis is now running: https://travis-ci.org/cta-observatory/dragonboard_testbench

maxnoe commented 8 years ago

We also need unit tests for everything else, we e. g. use the dummy files to test the reading and offset calculation.

maxnoe commented 8 years ago

I close this, as the ci is setup and first tests there.