Skip to content

Commit

Permalink
Add test for input dimension (#299)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniele Nerini <daniele.nerini@gmail.com>
  • Loading branch information
katelbach and dnerini committed Apr 27, 2024
1 parent 38cc191 commit 30c19e6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pysteps/tests/test_extrapolation_semilagrangian.py
Expand Up @@ -24,6 +24,26 @@ def test_semilagrangian():
assert_array_almost_equal(result, expected)


def test_wrong_input_dimensions():
p_1d = np.ones(8)
p_2d = np.ones((8, 8))
p_3d = np.ones((8, 8, 2))
v_2d = np.ones((8, 8))
v_3d = np.stack([v_2d, v_2d])

num_timesteps = 1

invalid_inputs = [
(p_1d, v_3d),
(p_2d, v_2d),
(p_3d, v_2d),
(p_3d, v_3d),
]
for precip, velocity in invalid_inputs:
with pytest.raises(ValueError):
extrapolate(precip, velocity, num_timesteps)


def test_ascending_time_step():
precip = np.ones((8, 8))
v = np.ones((8, 8))
Expand Down

0 comments on commit 30c19e6

Please sign in to comment.