-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_check_data.py
More file actions
60 lines (42 loc) · 1.67 KB
/
test_check_data.py
File metadata and controls
60 lines (42 loc) · 1.67 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import pytest
import numpy as np
from CheckData import CheckData
def test_check_data_type():
# Test that y and t are lists
with pytest.raises(ValueError):
CheckData([1, 2, 3], 4)
with pytest.raises(ValueError):
CheckData(1, [1, 2, 3])
def test_check_data_length():
# Test that y and t have the same length
with pytest.raises(ValueError):
CheckData([1, 2, 3], [1, 2, 3, 4])
'''def test_check_data():
#Test that all vectors are of the same length
with pytest.raises(ValueError):
CheckData([[1, 2], [4, 5, 6]], [[1, 2, 3], [4, 5]])'''
def test_check_data_type_members():
# Test that y and t members are numeric
with pytest.raises(ValueError):
CheckData([[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 'a']])
def test_check_data_time_order():
# Test that t is in ascending order
with pytest.raises(ValueError):
CheckData([[1, 2, 3], [4, 3, 2]], [[1, 2, 3], [4, 3, 2]])
def test_check_data_time_duplicates():
# Test that t does not contain duplicates
with pytest.raises(ValueError):
CheckData([[1, 2, 3], [4, 5, 6]], [[1, 1, 2], [4, 5, 6]])
def test_check_data_inf():
# Test that y does not contain Inf
with pytest.raises(ValueError):
CheckData([[1, 2, 3], [4, 5, np.inf]], [[1, 2, 3], [4, 5]])
def test_check_data_time_gap():
# Test that there is no large time gap
CheckData([[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]])
def test_check_data_no_warnings():
# Test that there are no warnings for a valid input
CheckData([[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]])
if __name__ == "__main__":
test_check_time_gaps()
print("All tests passed!")