File size: 426 Bytes
78661be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)