Skip to content

Commit 872f65a

Browse files
committed
Add test for visvlingam
1 parent 8de7284 commit 872f65a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tests/test_poly.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from numpy import array, pi
1+
from numpy import array, pi, roll
22
from pytest import approx
33

44
from py_eddy_tracker.poly import (
@@ -40,6 +40,14 @@ def test_convex_hull():
4040
def test_visvalingam():
4141
x = array([1, 2, 3, 4, 5, 6.75, 6, 1])
4242
y = array([-0.5, -1.5, -1, -1.75, -1, -1, -0.5, -0.5])
43+
x_target = [1, 2, 3, 4, 6, 1]
44+
y_target = [-0.5, -1.5, -1, -1.75, -0.5, -0.5]
4345
x_, y_ = visvalingam(x, y, 6)
44-
assert ([1, 2, 3, 4, 6, 1] == x_).all()
45-
assert ([-0.5, -1.5, -1, -1.75, -0.5, -0.5] == y_).all()
46+
assert (x_target == x_).all()
47+
assert (y_target == y_).all()
48+
x_, y_ = visvalingam(x[:-1], y[:-1], 6)
49+
assert (x_target == x_).all()
50+
assert (y_target == y_).all()
51+
x_, y_ = visvalingam(roll(x, 2), roll(y, 2), 6)
52+
assert (x_target[:-1] == x_[1:]).all()
53+
assert (y_target[:-1] == y_[1:]).all()

0 commit comments

Comments
 (0)