Skip to content

Commit cb79b47

Browse files
authored
Add test outlier detection (#298)
* Add test outlier detection * Update cleansing.py correcting input_array instead of coords in log message * Update test_utils_cleansing.py removed k parameter from cleansing.detect_outliers in test.test_utils_cleansing.test_detect_outlier_input_dims() because not necessary for test and coords is not passed.
1 parent 0cc4488 commit cb79b47

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pysteps/tests/test_utils_cleansing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,9 @@ def test_detect_outlier_multivariate_local():
174174
V[-1] = (-3, 3)
175175
outliers = cleansing.detect_outliers(V, 4, coord=X, k=50)
176176
assert outliers.sum() == 2
177+
178+
def test_detect_outlier_input_dims():
179+
V = np.zeros((20, 3, 2))
180+
thr_std_devs = 1
181+
with pytest.raises(ValueError):
182+
cleansing.detect_outliers(V, thr_std_devs)

pysteps/utils/cleansing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def detect_outliers(input_array, thr, coord=None, k=None, verbose=False):
172172
else:
173173
raise ValueError(
174174
f"input_array must have 1 (n) or 2 dimensions (n, m), "
175-
f"but it has {coord.ndim}"
175+
f"but it has {input_array.ndim}"
176176
)
177177

178178
if nsamples < 2:

0 commit comments

Comments
 (0)