-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_ref.py
39 lines (28 loc) · 1002 Bytes
/
test_ref.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Special test for teneva_bm (check reference values for all benchmarks).
Test that for a reference multi-index benchmark returns the expected value.
Run it as "clear && python test_ref.py" from the root folder of the project.
"""
import numpy as np
from teneva_bm import *
import unittest
class TestRef(unittest.TestCase):
def setUp(self):
self.eps = 1.E-16
def test_base(self):
for Bm in teneva_bm_get():
with self.subTest(Bm=Bm):
bm = Bm()
bm.prep()
try:
i, z = bm.ref
except NotImplementedError as e:
continue
i, z = bm.ref
y = bm.get(i)
e = np.abs(y - z)
msg = '\n>>> Ref. value does not match for '
msg += f'"{Bm.__name__}" [d={bm.d}; y={y}]'
self.assertLess(e, self.eps, msg)
if __name__ == '__main__':
np.random.seed(42)
unittest.main()