File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -121,8 +121,7 @@ def psisx(x, c):
121
121
res = np .zeros (len (x ))
122
122
mask = np .abs (x ) <= c
123
123
res [mask ] = 1
124
- res [~ mask ] = (c / np .abs (x ))[~ mask ]
125
- res [~ np .isfinite (x )] = 0
124
+ res [~ mask ] = c / np .abs (x [~ mask ])
126
125
return res
127
126
128
127
# Run the iterative reweighting algorithm to compute M-estimator.
Original file line number Diff line number Diff line change 1
1
import numpy as np
2
+ import pytest
2
3
3
4
from sklearn_extra .robust .mean_estimators import median_of_means , huber
4
5
@@ -21,3 +22,10 @@ def test_mom():
21
22
sample_cor = sample
22
23
sample_cor [:num_out ] = np .inf
23
24
assert np .abs (median_of_means (sample_cor , num_out , rng )) < 2
25
+
26
+
27
+ def test_huber ():
28
+ X = np .hstack ([np .zeros (90 ), np .ones (10 )])
29
+ with pytest .warns (None ) as record :
30
+ huber (X )
31
+ assert len (record ) == 0
You can’t perform that action at this time.
0 commit comments