Skip to content

Commit 7e8a4af

Browse files
authored
Test semilagrangian extrapolation with list of timesteps (#319)
1 parent 4065c88 commit 7e8a4af

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

pysteps/tests/test_extrapolation_semilagrangian.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,36 @@
66

77

88
def test_semilagrangian():
9-
"""Tests semilagrangian extrapolation."""
9+
"""Test semilagrangian extrapolation with number of timesteps."""
1010
# inputs
11-
precip = np.ones((8, 8))
11+
precip = np.zeros((8, 8))
12+
precip[0, 0] = 1
1213
v = np.ones((8, 8))
1314
velocity = np.stack([v, v])
1415
num_timesteps = 1
1516
# expected
16-
expected = np.ones((1, 8, 8))
17+
expected = np.zeros((1, 8, 8))
1718
expected[:, :, 0] = np.nan
1819
expected[:, 0, :] = np.nan
20+
expected[:, 1, 1] = 1
1921
# result
2022
result = extrapolate(precip, velocity, num_timesteps)
2123
assert_array_almost_equal(result, expected)
24+
25+
26+
def test_semilagrangian_timesteps():
27+
"""Test semilagrangian extrapolation with list of timesteps."""
28+
# inputs
29+
precip = np.zeros((8, 8))
30+
precip[0, 0] = 1
31+
v = np.ones((8, 8)) * 10
32+
velocity = np.stack([v, v])
33+
timesteps = [0.1]
34+
# expected
35+
expected = np.zeros((1, 8, 8))
36+
expected[:, :, 0] = np.nan
37+
expected[:, 0, :] = np.nan
38+
expected[:, 1, 1] = 1
39+
# result
40+
result = extrapolate(precip, velocity, timesteps)
41+
assert_array_almost_equal(result, expected)

0 commit comments

Comments
 (0)