Skip to content

Commit 5fcc477

Browse files
committed
📌 add tests for NaN and non-NaN resampler accordance
1 parent 590fa1d commit 5fcc477

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

tests/test_algos_python_compliance.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,33 @@ def test_nan_resampler_accordance(rust_python_pair, n, n_random_nans, n_out):
8484
rust_downsampler.downsample(x, y, n_out=n_out),
8585
python_downsampler.downsample(x, y, n_out=n_out),
8686
)
87+
88+
89+
@pytest.mark.parametrize(
90+
"nan_no_nan_pair",
91+
[
92+
(NaNFPCS_py(), FPCS_py()),
93+
(NaNM4_py(), M4_py()),
94+
(NaNMinMax_py(), MinMax_py()),
95+
(NaNMinMaxLTTB_py(), MinMaxLTTB_py()),
96+
(NaNFPCSDownsampler(), FPCSDownsampler()),
97+
(NaNM4Downsampler(), M4Downsampler()),
98+
(NaNMinMaxDownsampler(), MinMaxDownsampler()),
99+
(NaNMinMaxLTTBDownsampler(), MinMaxLTTBDownsampler()),
100+
],
101+
)
102+
@pytest.mark.parametrize("n", [10_000, 10_032, 20_321, 23_489])
103+
@pytest.mark.parametrize("n_out", [100, 200, 252])
104+
def test_nan_no_nan_resampler_accordance(nan_no_nan_pair, n, n_out):
105+
nan_downsampler, no_nan_downsampler = nan_no_nan_pair
106+
x = np.arange(n)
107+
y = np.random.randn(n)
108+
# Wihtout x passed to the downsamplers
109+
nan_result = nan_downsampler.downsample(y, n_out=n_out)
110+
no_nan_result = no_nan_downsampler.downsample(y, n_out=n_out)
111+
assert np.allclose(nan_result, no_nan_result)
112+
113+
# With x passed to the downsamplers
114+
nan_result = nan_downsampler.downsample(x, y, n_out=n_out)
115+
no_nan_result = no_nan_downsampler.downsample(x, y, n_out=n_out)
116+
assert np.allclose(nan_result, no_nan_result)

0 commit comments

Comments
 (0)