Mercurial > hg > tvii
comparison tests/test_error.py @ 70:351fc97bb996
add error computation + test functions
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 17 Dec 2017 13:22:44 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
69:0bb36ae047c3 | 70:351fc97bb996 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 """ | |
4 test error computation functionality | |
5 """ | |
6 | |
7 import numpy as np | |
8 import os | |
9 import unittest | |
10 from tvii import error | |
11 | |
12 class ErrorTest(unittest.TestCase): | |
13 | |
14 def test_error_computation(self): | |
15 """test error computation""" | |
16 | |
17 def square(x): | |
18 return x*x | |
19 | |
20 x = [[1], [2], [3]] | |
21 y = np.array([0, 3, 8]) | |
22 | |
23 yhat, _err = error.error(square, x, y) | |
24 | |
25 assert list(yhat) == [1, 4, 9] | |
26 assert list(_err) == [1, 1, 1] | |
27 | |
28 if __name__ == '__main__': | |
29 unittest.main() |