def test_munkres(self): perm = [1, 0, 2] coords1 = self.coords.copy() coords2 = self.coords.copy()[perm] dist1, perm_calc1 = find_best_permutation( coords1.copy(), coords2, reshape=False, user_algorithm=find_permutations_hungarian ) dist2, perm_calc2 = find_best_permutation( coords1.copy(), coords2, reshape=False, user_algorithm=find_permutations_munkres ) self.assertEqual(perm_calc1, perm_calc2)
def test_munkres(self): perm = [1, 0, 2] coords1 = self.coords.copy() coords2 = self.coords.copy()[perm] dist1, perm_calc1 = find_best_permutation(coords1.copy(), coords2, reshape=False, user_algorithm=find_permutations_hungarian) dist2, perm_calc2 = find_best_permutation(coords1.copy(), coords2, reshape=False, user_algorithm=find_permutations_munkres) self.assertEqual(perm_calc1, perm_calc2)
def test_nonpermutable(self): coords1 = self.coords.copy() coords2 = self.coords.copy()[[0, 2, 1, 3]] dist, perm_calc = find_best_permutation( coords1, coords2, reshape=False, permlist=self.permlist, user_algorithm=find_permutations_OPTIM ) self.assertItemsEqual(perm_calc, [0, 2, 1, 3])
def check_perm(self, perm): coords1 = self.coords.copy() coords2 = self.coords.copy()[perm] dist, perm_calc = find_best_permutation(coords1, coords2, reshape=False, user_algorithm=find_permutations_OPTIM) self.assertItemsEqual(perm, perm_calc) self.assertAlmostEqual(np.linalg.norm(coords1 - self.coords), 0.0) self.assertAlmostEqual(np.linalg.norm(coords2[perm_calc] - self.coords), 0.0)
def test_nonpermutable(self): coords1 = self.coords.copy() coords2 = self.coords.copy()[[0, 2, 1, 3]] dist, perm_calc = find_best_permutation(coords1, coords2, reshape=False, permlist=self.permlist, user_algorithm = find_permutations_OPTIM) self.assertItemsEqual(perm_calc, [0, 2, 1, 3])
def check_perm(self, perm): coords1 = self.coords.copy() coords2 = self.coords.copy()[perm] dist, perm_calc = find_best_permutation(coords1, coords2, reshape=False, user_algorithm = find_permutations_OPTIM) self.assertItemsEqual(perm, perm_calc) self.assertAlmostEqual(np.linalg.norm(coords1 - self.coords), 0.) self.assertAlmostEqual(np.linalg.norm(coords2[perm_calc] - self.coords), 0.)
def check_perm(self, perm): coords1 = self.coords.copy() coords2 = self.coords.copy()[perm] dist, perm_calc = find_best_permutation(coords1, coords2, reshape=False, permlist=self.permlist, user_algorithm = find_permutations_OPTIM) try: self.assertItemsEqual(perm, perm_calc) except AttributeError: self.assertCountEqual(perm, perm_calc) self.assertAlmostEqual(np.linalg.norm(coords1 - self.coords), 0.) self.assertAlmostEqual(np.linalg.norm(coords2[perm] - self.coords), 0.)
def check_perm(self, perm): coords1 = self.coords.copy() coords2 = self.coords.copy()[perm] dist, perm_calc = find_best_permutation( coords1, coords2, reshape=False, permlist=self.permlist, user_algorithm=find_permutations_OPTIM) try: self.assertItemsEqual(perm, perm_calc) except AttributeError: self.assertCountEqual(perm, perm_calc) self.assertAlmostEqual(np.linalg.norm(coords1 - self.coords), 0.) self.assertAlmostEqual(np.linalg.norm(coords2[perm] - self.coords), 0.)
def find_permutation(self, X1, X2): return find_best_permutation(X1, X2, self.permlist, box_lengths=self.boxlengths)