def test_unify_not_full_dims_different_dims(self): cs.init(3, {0:[0,1], 1:[2]}) c1 = Cuboid([1,2,3],[7,8,9], {0:[0,1], 1:[2]}) c2 = Cuboid([4,5,float("-inf")],[7,7,float("inf")], {0:[0,1]}) s1 = Core([c1], {0:[0,1], 1:[2]}) s2 = Core([c2], {0:[0,1]}) with self.assertRaises(Exception): s1.unify_with(s2)
def test_unify_not_full_dims_same_dims(self): cs.init(3, {0:[0,1], 1:[2]}) c1 = Cuboid([1,2,float("-inf")],[7,8,float("inf")], {0:[0,1]}) c2 = Cuboid([4,5,float("-inf")],[8,7,float("inf")], {0:[0,1]}) s1 = Core([c1], {0:[0,1]}) s2 = Core([c2], {0:[0,1]}) s_result = Core([c1, c2], {0:[0,1]}) self.assertEqual(s1.unify_with(s2), s_result) self.assertEqual(s1.unify_with(s2), s2.unify_with(s1))
def test_unify_no_repair(self): cs.init(3, {0:[0,1,2]}) c1 = Cuboid([1,2,3],[7,8,9], {0:[0,1,2]}) c2 = Cuboid([4,5,6],[7,9,7], {0:[0,1,2]}) s1 = Core([c1], {0:[0,1,2]}) s2 = Core([c2], {0:[0,1,2]}) s_result = Core([c1, c2], {0:[0,1,2]}) self.assertEqual(s1.unify_with(s2), s_result) self.assertEqual(s1.unify_with(s2), s2.unify_with(s1))
def test_unify_repair(self): cs.init(3, {0:[0,1,2]}) c1 = Cuboid([1,2,3],[2,3,4], {0:[0,1,2]}) c2 = Cuboid([3,4,5],[7,7,7], {0:[0,1,2]}) s1 = Core([c1], {0:[0,1,2]}) s2 = Core([c2], {0:[0,1,2]}) c1_result = Cuboid([1,2,3],[3.25,4,4.75], {0:[0,1,2]}) c2_result = Cuboid([3,4,4.75],[7,7,7], {0:[0,1,2]}) s_result = Core([c1_result, c2_result], {0:[0,1,2]}) self.assertEqual(s1.unify_with(s2), s_result) self.assertEqual(s1.unify_with(s2), s2.unify_with(s1))
def test_unify_no_core(self): cs.init(3, {0:[0,1,2]}) c = Cuboid([1,2,3],[7,8,9], {0:[0,1,2]}) s = Core([c], {0:[0,1,2]}) with self.assertRaises(Exception): s.unify_with(42)