@@ -17,24 +17,28 @@ def test_partition_function():
1717def test_hidalgo_zero_distance_stability ():
1818 """
1919 Test Hidalgo segmenter with duplicate/near-duplicate points.
20-
20+
2121 Regression test for issue #3068: AssertionError when data contains
2222 identical rows, causing zero distances in nearest neighbor search.
2323 This should not crash but handle duplicates gracefully.
2424 """
2525 # Create data with exact duplicates (causes zero distances)
26- X = np .array ([[0.1 , 0.2 , 0.3 ],
27- [0.1 , 0.2 , 0.3 ], # Exact duplicate
28- [0.4 , 0.5 , 0.6 ],
29- [0.7 , 0.8 , 0.9 ],
30- [0.7 , 0.8 , 0.9 ]]) # Another duplicate
31-
26+ X = np .array (
27+ [
28+ [0.1 , 0.2 , 0.3 ],
29+ [0.1 , 0.2 , 0.3 ], # Exact duplicate
30+ [0.4 , 0.5 , 0.6 ],
31+ [0.7 , 0.8 , 0.9 ],
32+ [0.7 , 0.8 , 0.9 ],
33+ ]
34+ ) # Another duplicate
35+
3236 # This should not raise AssertionError or divide-by-zero warnings
3337 hidalgo = HidalgoSegmenter (K = 2 , q = 2 , n_iter = 100 , burn_in = 0.5 )
34-
38+
3539 # Should complete without errors
3640 result = hidalgo .fit_predict (X , axis = 0 )
37-
41+
3842 # Basic sanity checks
3943 assert result is not None
4044 assert len (result ) >= 0 # May return empty array if no changepoints
@@ -44,17 +48,16 @@ def test_hidalgo_zero_distance_stability():
4448def test_hidalgo_normal_data ():
4549 """
4650 Test Hidalgo segmenter with normal random data.
47-
51+
4852 Verifies that the fix doesn't break normal operation.
4953 """
5054 # Random data without duplicates
5155 rng = np .random .RandomState (42 )
5256 X = rng .rand (50 , 3 )
53-
57+
5458 hidalgo = HidalgoSegmenter (K = 3 , q = 3 , n_iter = 200 , burn_in = 0.8 )
5559 result = hidalgo .fit_predict (X , axis = 0 )
56-
60+
5761 # Should work as before
5862 assert result is not None
5963 assert isinstance (result , np .ndarray )
60-
0 commit comments