Skip to content

Commit 1b2c4c7

Browse files
committed
Add wrapping longitude test
1 parent 2ba0d2a commit 1b2c4c7

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/test_generic.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from numpy import arange, array, nan, ones, zeros
22

3-
from py_eddy_tracker.generic import cumsum_by_track, simplify
3+
from py_eddy_tracker.generic import cumsum_by_track, simplify, wrap_longitude
44

55

66
def test_simplify():
@@ -30,3 +30,22 @@ def test_cumsum_by_track():
3030
a = ones(10, dtype="i4") * 2
3131
track = array([1, 1, 2, 2, 2, 2, 44, 44, 44, 48])
3232
assert (cumsum_by_track(a, track) == [2, 4, 2, 4, 6, 8, 2, 4, 6, 2]).all()
33+
34+
35+
def test_wrapping():
36+
y = x = arange(-5,5, dtype='f4')
37+
x_, _ = wrap_longitude(x, y, ref=-10)
38+
assert (x_ == x).all()
39+
x_, _ = wrap_longitude(x, y, ref=1)
40+
assert x.size == x_.size
41+
assert (x_[6:] == x[6:]).all()
42+
assert (x_[:6] == x[:6] + 360).all()
43+
x_, _ = wrap_longitude(x, y, ref=1, cut=True)
44+
assert x.size + 3 == x_.size
45+
assert (x_[6 + 3:] == x[6:]).all()
46+
assert (x_[:7] == x[:7] + 360).all()
47+
48+
# FIXME Need evolution in wrap_longitude
49+
# x %= 360
50+
# x_, _ = wrap_longitude(x, y, ref=-10, cut=True)
51+
# assert x.size == x_.size

0 commit comments

Comments
 (0)