def test_midpoint_three_cuboids(self): cs.init(3, {0: [0], 1: [1, 2]}) c1 = Cuboid([1, 2, 3], [4, 5, 6], {0: [0], 1: [1, 2]}) c2 = Cuboid([3, 2, 1], [6, 5, 4], {0: [0], 1: [1, 2]}) c3 = Cuboid([1, 3, 2], [5, 4, 6], {0: [0], 1: [1, 2]}) s = Core([c1, c2, c3], {0: [0], 1: [1, 2]}) self.assertEqual(s.midpoint(), [3.5, 3.5, 3.5])
def test_midpoint_two_cuboids_infinity(self): cs.init(3, {0: [0], 1: [1, 2]}) c1 = Cuboid([-float("inf"), 2, 3], [float("inf"), 5, 6], {1: [1, 2]}) c2 = Cuboid([-float("inf"), 1, 1], [float("inf"), 4, 4], {1: [1, 2]}) s = Core([c1, c2], {1: [1, 2]}) self.assertEqual(s.midpoint(), [0, 3, 3.5])
def test_midpoint_single_cuboid(self): cs.init(3, {0: [0, 1, 2]}) c = Cuboid([1, 2, 3], [4, 5, 6], {0: [0, 1, 2]}) s = Core([c], {0: [0, 1, 2]}) self.assertEqual(s.midpoint(), [2.5, 3.5, 4.5])