import numpy as np import scipr from scipr.matching import Closest, Hungarian, Greedy, MNN from scipr.transform import Affine, Rigid, StackedAutoEncoder np.random.seed(1817) A = np.random.random((10, 100)) B = np.random.random((20, 100)) matchers = [Closest(), Greedy(), Hungarian(), MNN()] for match in matchers: transform = Affine() model = scipr.SCIPR(match, transform, n_iter=2) model.fit(A, B) A_new = model.transform(A) assert(np.all(np.not_equal(A, A_new)))
def test_009_greedy_D2C_alpha_05(self): """Test greedy matching strategy D -> C with alpha=0.5""" match = Greedy(alpha=0.5, beta=2) d_idx, c_idx, distances = match(self.D, self.C, self.kd_C) self.assertTrue(np.array_equal(d_idx, [0, 1])) self.assertTrue(np.array_equal(c_idx, [0, 0]))
def test_007_greedy_D2C_beta_1(self): """Test greedy matching strategy D -> C with beta=1""" match = Greedy(alpha=1, beta=1) d_idx, c_idx, distances = match(self.D, self.C, self.kd_C) self.assertTrue(np.array_equal(d_idx, [0, 1, 2])) self.assertTrue(np.array_equal(c_idx, [0, 2, 1]))
def test_008_greedy_C2D_alpha_05(self): """Test greedy matching strategy C -> D with alpha=0.5""" match = Greedy(alpha=0.5, beta=2) c_idx, d_idx, distances = match(self.C, self.D, self.kd_D) self.assertTrue(np.array_equal(c_idx, [0, 1])) self.assertTrue(np.array_equal(d_idx, [0, 2]))
def test_006_greedy_C2D_beta_1(self): """Test greedy matching strategy C -> D with beta=1""" match = Greedy(alpha=1, beta=1) c_idx, d_idx, distances = match(self.C, self.D, self.kd_D) self.assertTrue(np.array_equal(c_idx, [0, 1, 2])) self.assertTrue(np.array_equal(d_idx, [0, 2, 1]))