Skip to content

Commit 38ca9cd

Browse files
committed
Add a regression test to ensure Hidalgo handles duplicate rows without errors
1 parent 816577a commit 38ca9cd

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

aeon/segmentation/tests/test_hidalgo.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,33 @@ def test_partition_function():
99
assert p == 8.0
1010
b = _binom(10, 2)
1111
assert b == 45.0
12+
13+
14+
def test_hidalgo_zero_distance_duplicate_rows():
15+
"""Test that Hidalgo handles duplicate rows without numerical errors."""
16+
import numpy as np
17+
18+
from aeon.segmentation._hidalgo import HidalgoSegmenter
19+
20+
X = np.array(
21+
[
22+
[1.0, 2.0, 3.0],
23+
[1.0, 2.0, 3.0],
24+
[4.0, 5.0, 6.0],
25+
[7.0, 8.0, 9.0],
26+
]
27+
)
28+
29+
seg = HidalgoSegmenter(
30+
K=2,
31+
q=2,
32+
n_iter=50,
33+
burn_in=0.2,
34+
sampling_rate=5,
35+
seed=1,
36+
)
37+
38+
out = seg.fit_predict(X, axis=0)
39+
assert out is not None
40+
assert isinstance(out, np.ndarray)
41+
assert len(out) == len(X)

0 commit comments

Comments
 (0)