-
Notifications
You must be signed in to change notification settings - Fork 19
/
test_all.py
53 lines (38 loc) · 1023 Bytes
/
test_all.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import sys
import os
import numpy as np
import pytest
from frechetdist import frdist
TEST_CASES = [
{
'P': [[1, 1], [2, 1], [2, 2]],
'Q': [[2, 2], [0, 1], [2, 4]],
'expected': 2.0
},
{
'P': np.array((np.linspace(0.0, 1.0, 100), np.ones(100))).T,
'Q': np.array((np.linspace(0.0, 1.0, 100), np.ones(100))).T,
'expected': 0
},
{
'P': [[-1, 0], [0, 1], [1, 0], [0, -1]],
'Q': [[-2, 0], [0, 2], [2, 0], [0, -2]],
'expected': 1.0
},
{
'P': np.array((np.linspace(0.0, 1.0, 100), np.ones(100)*2)).T,
'Q': np.array((np.linspace(0.0, 1.0, 100), np.ones(100))).T,
'expected': 1.0
}
]
def test_main():
for test_case in TEST_CASES:
P = test_case['P']
Q = test_case['Q']
eo = test_case['expected']
assert frdist(P, Q) == eo
def test_errors():
P = []
Q = [[2, 2], [0, 1], [2, 4]]
with pytest.raises(ValueError):
assert frdist(P, Q) == 2.0