Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test for visvlingam
  • Loading branch information
AntSimi committed Apr 5, 2021
commit 872f65ad7a0bec68848d3d7dbff4567c9141e7f8
14 changes: 11 additions & 3 deletions tests/test_poly.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from numpy import array, pi
from numpy import array, pi, roll
from pytest import approx

from py_eddy_tracker.poly import (
Expand Down Expand Up @@ -40,6 +40,14 @@ def test_convex_hull():
def test_visvalingam():
x = array([1, 2, 3, 4, 5, 6.75, 6, 1])
y = array([-0.5, -1.5, -1, -1.75, -1, -1, -0.5, -0.5])
x_target = [1, 2, 3, 4, 6, 1]
y_target = [-0.5, -1.5, -1, -1.75, -0.5, -0.5]
x_, y_ = visvalingam(x, y, 6)
assert ([1, 2, 3, 4, 6, 1] == x_).all()
assert ([-0.5, -1.5, -1, -1.75, -0.5, -0.5] == y_).all()
assert (x_target == x_).all()
assert (y_target == y_).all()
x_, y_ = visvalingam(x[:-1], y[:-1], 6)
assert (x_target == x_).all()
assert (y_target == y_).all()
x_, y_ = visvalingam(roll(x, 2), roll(y, 2), 6)
assert (x_target[:-1] == x_[1:]).all()
assert (y_target[:-1] == y_[1:]).all()