Commit 70fb3adf authored by lucas_miranda's avatar lucas_miranda
Browse files

Adds tests for outlier interpolation functions

parent 4b284e8d
Pipeline #92655 passed with stage
in 22 minutes and 15 seconds
......@@ -430,7 +430,7 @@ def full_outlier_mask(
"""
body_parts = experiment.columns.levels[0]
full_mask = experiment.copy()
full_mask = experiment.copy().drop(exclude, axis=1)
for bpart in body_parts:
if bpart != exclude:
mask = mask_outliers(
......@@ -481,6 +481,7 @@ def interpolate_outliers(
mask = full_outlier_mask(
experiment, likelihood, likelihood_tolerance, exclude, lag, n_std, mode
)
interpolated_exp[mask] = np.nan
interpolated_exp.interpolate(
method="linear", limit=limit, limit_direction="both", inplace=True
......
......@@ -351,6 +351,7 @@ def test_smooth_mult_trajectory(alpha, series):
assert autocorr(smoothed2) <= autocorr(smoothed1)
@settings(deadline=None)
@given(mode=st.one_of(st.just("and"), st.just("or")))
def test_interpolate_outliers(mode):
......@@ -367,27 +368,38 @@ def test_interpolate_outliers(mode):
coords_name = list(coords.keys())[0]
interp = interpolate_outliers(
coords[coords_name], lkhood[coords_name], 0.9, exclude="Center", mode=mode
coords[coords_name],
lkhood[coords_name],
0.999,
exclude="Center",
mode=mode,
limit=100,
n_std=1,
)
assert (
full_outlier_mask(
interp,
lkhood,
lkhood[coords_name],
likelihood_tolerance=0.9,
exclude="Center",
lag=5,
n_std=2,
mode=mode,
).sum()
)
.sum()
.sum()
< full_outlier_mask(
coords,
lkhood,
coords[coords_name],
lkhood[coords_name],
likelihood_tolerance=0.9,
exclude="Center",
lag=5,
n_std=2,
mode=mode,
).sum()
)
.sum()
.sum()
)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment