acra-backend / code /tests /test_fcm.py
Zeref8425's picture
Deploy backend snapshot
78661be
Raw History Blame Contribute Delete
426 Bytes
import numpy as np
from pipeline.fcm import run_fcm
def test_fcm_keeps_centers_finite_when_clusters_are_empty():
lab = np.zeros((64, 64, 3), dtype=np.float64)
lab[:32, :, 0] = 50.0
lab[32:, :, 0] = 70.0
centers, memberships = run_fcm(lab, n_clusters=16)
assert np.isfinite(centers).all()
assert np.isfinite(memberships).all()
np.testing.assert_allclose(memberships.sum(axis=1), 1.0, atol=1e-6)