-
Notifications
You must be signed in to change notification settings - Fork 230
Open
Description
I've been encountering sporadic test failures due to the test_kmeans_three_clusters test
Running it in a loop seems to show instability in the results of kmeans
#[test]
fn test_kmeans_three_clusters_loop() {
let points = [
// Cluster 1
point!(x: 0.0, y: 0.0),
point!(x: 1.0, y: 0.0),
// Cluster 2
point!(x: 10.0, y: 10.0),
point!(x: 11.0, y: 10.0),
// Cluster 3
point!(x: 20.0, y: 20.0),
point!(x: 21.0, y: 20.0),
];
for i in 0..100_000 {
let labels = points.kmeans(3).unwrap();
// Each pair should be in the same cluster
assert_eq!(labels[0], labels[1],"failed at loop {}",i);
assert_eq!(labels[2], labels[3],"failed at loop {}",i);
assert_eq!(labels[4], labels[5],"failed at loop {}",i);
// All three pairs should be in different clusters
assert_ne!(labels[0], labels[2],"failed at loop {}",i);
assert_ne!(labels[2], labels[4],"failed at loop {}",i);
assert_ne!(labels[0], labels[4],"failed at loop {}",i);
}
}urschrei
Metadata
Metadata
Assignees
Labels
No labels