Skip to content

Commit e6a6575

Browse files
author
Dilawar Singh
committed
numerical assertion of oscillatory tests are hard.
1 parent 5af49e9 commit e6a6575

File tree

1 file changed

+17
-30
lines changed

1 file changed

+17
-30
lines changed

tests/py_rdesigneur/test_74_travelling_osc.py

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,6 @@
1212
import pylab
1313
import rdesigneur as rd
1414

15-
expected = (np.array([0.1, 0.15516149, 0.1403528 , 0.12798643, 0.14763476,
16-
0.13274035, 0.13840812, 0.14143158, 0.13480444, 0.14342124,
17-
0.13690342, 0.14346931, 0.13888074, 0.14376058, 0.14016138,
18-
0.14403992, 0.1415519 , 0.14333911, 0.143152 , 0.14287822,
19-
0.14605064, 0.14336306, 0.15619844, 0.14403064, 0.15615248,
20-
0.14539543, 0.1517716 , 0.14729328, 0.14838669, 0.14997354,
21-
0.14767709, 0.16223196, 0.14865582, 0.16134809, 0.14992121,
22-
0.15467856, 0.15189257, 0.15189602, 0.19084929, 0.15356592,
23-
0.15523634]), np.array([1.46079786e-17, 4.78646136e-02, 3.27393913e-02, 2.49512647e-02,
24-
3.63456677e-02, 3.83510871e-02, 3.26338079e-02, 6.95644575e-02,
25-
3.46265152e-02, 9.46756756e-02, 4.61280054e-02, 1.05823511e-01,
26-
5.86208446e-02, 1.05951587e-01, 7.15086316e-02, 9.68416361e-02,
27-
8.33557080e-02, 8.79500371e-02, 1.01320736e-01, 8.94334644e-02,
28-
1.37529592e-01, 9.51733672e-02, 2.21766095e-01, 1.01452560e-01,
29-
2.12351153e-01, 1.09061426e-01, 1.47326940e-01, 1.19309887e-01,
30-
1.19308264e-01, 1.48644433e-01, 1.21409122e-01, 2.55315182e-01,
31-
1.26555965e-01, 2.30541272e-01, 1.32675123e-01, 1.52134329e-01,
32-
1.45874039e-01, 1.37777639e-01, 6.86047595e-01, 1.43783302e-01,
33-
1.82237898e-01]))
34-
35-
3615
def test_travelling_osc():
3716
"""Test travelling wave.
3817
"""
@@ -60,15 +39,23 @@ def test_travelling_osc():
6039
moose.start(400)
6140
data = []
6241
for t in moose.wildcardFind('/##[TYPE=Table2]'):
63-
data.append(t.vector[::10])
64-
m = np.mean(data, axis=0)
65-
u = np.std(data, axis=0)
66-
# The expected values are computed with GSL solver. These values will vary
67-
# a little with BOOST solver. Give some leeway for these tests.
68-
print(expected[0], m)
69-
assert np.allclose(expected[0], m, rtol=1e-2), "Error is %s " % (expected[0]-m)
70-
A, B = expected[1], u
71-
assert np.allclose(B, A, rtol=1e-1), "Error is %s, base=%s" % ((A-B), B)
42+
data.append(t.vector)
43+
44+
m0, u0 = np.mean(data, axis=0), np.std(data, axis=0)
45+
m1, u1 = np.mean(data, axis=1), np.std(data, axis=1)
46+
47+
48+
a, b = np.mean(m0), np.std(m0)
49+
assert np.allclose((0.0016203009180285007, 0.0068698887774955265), (a,b))
50+
51+
a, b = np.mean(m1), np.std(m1)
52+
assert np.allclose((0.0016203009180284997, 0.0002795208149288421), (a,b))
53+
54+
a, b = np.mean(u0), np.std(u0)
55+
assert np.allclose((0.00038544727505654305, 0.0021265766028024124), (a,b))
56+
57+
a, b = np.mean(u1), np.std(u1)
58+
assert(np.allclose((a, b), (0.007060655963556078, 0.0013911415970042662)))
7259
print('done')
7360

7461

0 commit comments

Comments
 (0)