Skip to content

Commit 95b29af

Browse files
committedMar 4, 2025·
💨 formatting + adding more tests
1 parent 0339deb commit 95b29af

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed
 

‎tests/test_algos_python_compliance.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
LTTBDownsampler,
77
M4Downsampler,
88
MinMaxDownsampler,
9-
# MinMaxLTTBDownsampler,
9+
MinMaxLTTBDownsampler,
1010
NaNFPCSDownsampler,
1111
NaNM4Downsampler,
1212
NaNMinMaxDownsampler,
13-
# NaNMinMaxLTTBDownsampler,
13+
NaNMinMaxLTTBDownsampler,
1414
)
1515
from tsdownsample._python.downsamplers import (
1616
FPCS_py,
1717
LTTB_py,
1818
M4_py,
1919
MinMax_py,
20-
# MinMaxLTTB_py,
20+
MinMaxLTTB_py,
2121
NaNFPCS_py,
2222
NaNM4_py,
2323
NaNMinMax_py,
24-
# NaNMinMaxLTTB_py,
24+
NaNMinMaxLTTB_py,
2525
)
2626

2727

@@ -31,12 +31,12 @@
3131
(MinMaxDownsampler(), MinMax_py()),
3232
(M4Downsampler(), M4_py()),
3333
(LTTBDownsampler(), LTTB_py()),
34-
# (MinMaxLTTBDownsampler(), MinMaxLTTB_py()),
34+
(MinMaxLTTBDownsampler(), MinMaxLTTB_py()),
3535
(FPCSDownsampler(), FPCS_py()),
3636
# Include NaN downsamplers
3737
(NaNMinMaxDownsampler(), NaNMinMax_py()),
3838
(NaNM4Downsampler(), NaNM4_py()),
39-
# (NaNMinMaxLTTBDownsampler(), NaNMinMaxLTTB_py()),
39+
(NaNMinMaxLTTBDownsampler(), NaNMinMaxLTTB_py()),
4040
(NaNFPCSDownsampler(), NaNFPCS_py()),
4141
],
4242
)
@@ -63,7 +63,7 @@ def test_resampler_accordance(rust_python_pair, n, n_out):
6363
[
6464
(NaNMinMaxDownsampler(), NaNMinMax_py()),
6565
(NaNM4Downsampler(), NaNM4_py()),
66-
# (NaNMinMaxLTTBDownsampler(), NaNMinMaxLTTB_py()),
66+
(NaNMinMaxLTTBDownsampler(), NaNMinMaxLTTB_py()),
6767
(NaNFPCSDownsampler(), NaNFPCS_py()),
6868
],
6969
)

‎tests/test_tsdownsample.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
from tsdownsample import ( # MeanDownsampler,; MedianDownsampler,
88
EveryNthDownsampler,
9+
FPCSDownsampler,
910
LTTBDownsampler,
1011
M4Downsampler,
1112
MinMaxDownsampler,
1213
MinMaxLTTBDownsampler,
14+
NaNFPCSDownsampler,
1315
NaNM4Downsampler,
1416
NaNMinMaxDownsampler,
1517
NaNMinMaxLTTBDownsampler,
@@ -28,12 +30,14 @@
2830
M4Downsampler(),
2931
LTTBDownsampler(),
3032
MinMaxLTTBDownsampler(),
33+
FPCSDownsampler(),
3134
]
3235

3336
RUST_NAN_DOWNSAMPLERS = [
3437
NaNMinMaxDownsampler(),
3538
NaNM4Downsampler(),
3639
NaNMinMaxLTTBDownsampler(),
40+
NaNFPCSDownsampler(),
3741
]
3842

3943
OTHER_DOWNSAMPLERS = [EveryNthDownsampler()]
@@ -167,8 +171,12 @@ def test_downsampling_with_gaps_in_x(downsampler: AbstractDownsampler):
167171
idx = np.arange(len(arr))
168172
idx[: len(idx) // 2] += len(idx) // 2 # add large gap in x
169173
s_downsampled = downsampler.downsample(idx, arr, n_out=100)
170-
assert len(s_downsampled) <= 100
171-
assert len(s_downsampled) >= 66
174+
if "FPCS" in downsampler.__class__.__name__:
175+
assert len(s_downsampled) >= 100
176+
assert len(s_downsampled) <= 200
177+
else:
178+
assert len(s_downsampled) <= 100
179+
assert len(s_downsampled) >= 66
172180

173181

174182
@pytest.mark.parametrize("downsampler", generate_rust_downsamplers())

‎tsdownsample/_python/downsamplers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def _downsample(
9393
LTTB_py._argmax_area(
9494
prev_x=x[a],
9595
prev_y=y[a],
96-
# NOTE: In a 100% correct implementation of LTTB the next x average
96+
# NOTE: In a 100% correct implementation of LTTB the next x average
9797
# should be implemented as the following:
9898
# avg_next_x=np.mean(x[offset[i + 1] : offset[i + 2]]),
9999
# To improve performance we use the following approximation

0 commit comments

Comments
 (0)
Please sign in to comment.