Skip to content

Commit 30c19e6

Browse files
katelbachdnerini
andauthored
Add test for input dimension (#299)
Co-authored-by: Daniele Nerini <daniele.nerini@gmail.com>
1 parent 38cc191 commit 30c19e6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pysteps/tests/test_extrapolation_semilagrangian.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,26 @@ def test_semilagrangian():
2424
assert_array_almost_equal(result, expected)
2525

2626

27+
def test_wrong_input_dimensions():
28+
p_1d = np.ones(8)
29+
p_2d = np.ones((8, 8))
30+
p_3d = np.ones((8, 8, 2))
31+
v_2d = np.ones((8, 8))
32+
v_3d = np.stack([v_2d, v_2d])
33+
34+
num_timesteps = 1
35+
36+
invalid_inputs = [
37+
(p_1d, v_3d),
38+
(p_2d, v_2d),
39+
(p_3d, v_2d),
40+
(p_3d, v_3d),
41+
]
42+
for precip, velocity in invalid_inputs:
43+
with pytest.raises(ValueError):
44+
extrapolate(precip, velocity, num_timesteps)
45+
46+
2747
def test_ascending_time_step():
2848
precip = np.ones((8, 8))
2949
v = np.ones((8, 8))

0 commit comments

Comments
 (0)