-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_notebook.py
More file actions
46 lines (34 loc) · 1.7 KB
/
test_notebook.py
File metadata and controls
46 lines (34 loc) · 1.7 KB
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
40
41
42
43
44
45
46
import pytest
from notebook import *
import numpy as np
def test_common_parameters():
computed, expected = common_parameters()
# Iterate over each variable in expected values and compare with computed ones
for key in expected:
expected_val = expected[key]['value']
computed_val = computed[key]['value']
atol = expected[key]['atol']
if computed_val is None or not np.allclose(expected_val, computed_val, atol=atol):
raise AssertionError(f"Mismatch in {key}. Your {key} value is different from the one expected.")
def test_signals():
computed, expected = signals()
# Iterate over each variable in expected values and compare with computed ones
for key in expected:
expected_val = expected[key]['value']
computed_val = computed[key]['value']
atol = expected[key]['atol']
if computed_val is None or not np.allclose(expected_val, computed_val, atol=atol):
raise AssertionError(f"Mismatch in {key}. Your {key} value is different from the one expected.")
def test_signals_second():
computed, expected = signals_second()
# Iterate over each variable in expected values and compare with computed ones
for key in expected:
print(key)
expected_val = expected[key]['value']
computed_val = computed[key]['value']
atol = expected[key]['atol']
if computed_val is None or not np.allclose(expected_val, computed_val, atol=atol):
raise AssertionError(f"Mismatch in {key}. Your {key} value is different from the one expected.")
# This will run the test if the file is run directly
if __name__ == "__main__":
pytest.main()