acra-backend / code /tests /test_auto_clusters.py
Zeref8425's picture
Deploy backend snapshot
78661be
Raw History Blame Contribute Delete
505 Bytes
import numpy as np
from pipeline.auto_clusters import estimate_n_clusters
def test_tiny_image_returns_k_min_of_two():
tiny = np.zeros((5, 5, 3), dtype=np.float64)
assert estimate_n_clusters(tiny) == 2
def test_red_green_image_enforces_cluster_floor():
lab = np.zeros((200, 200, 3), dtype=np.float64)
lab[:, :, 0] = 50
lab[:, :100, 1] = 40
lab[:, 100:, 1] = -40
lab[:, :, 2] = 10
k = estimate_n_clusters(lab)
assert k >= 12, f"red/green floor should be 12, got {k}"