Skip to content

Commit cf142c1

Browse files
Add test cleansing error is raise when input has nans (#296)
Co-authored-by: Daniele Nerini <[email protected]>
1 parent 3c18031 commit cf142c1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pysteps/tests/test_utils_cleansing.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ def test_decluster():
6262
assert np.all(V_dec == np.median(V, axis=0))
6363

6464

65+
def test_decluster_value_error_is_raise_when_input_has_nan():
66+
coords = np.ones((3, 1))
67+
input_array = np.ones((3, 1))
68+
69+
input_array[1, 0] = np.nan
70+
with pytest.raises(ValueError):
71+
cleansing.decluster(coords, input_array, scale=20)
72+
73+
6574
def test_detect_outlier_constant():
6675
"""Test that a constant input produces no outliers and that warnings are raised"""
6776

@@ -176,8 +185,8 @@ def test_detect_outlier_multivariate_local():
176185
assert outliers.sum() == 2
177186

178187

179-
def test_detect_outlier_input_dims():
180-
V = np.zeros((20, 3, 2))
188+
def test_detect_outlier_wrong_input_dims_raise_error():
189+
input_array = np.zeros((20, 3, 2))
181190
thr_std_devs = 1
182191
with pytest.raises(ValueError):
183-
cleansing.detect_outliers(V, thr_std_devs)
192+
cleansing.detect_outliers(input_array, thr_std_devs)

0 commit comments

Comments
 (0)