def test_vertical_y(self): boxtype = clp.BoxType(self.dim, (0,1,1)) permutations = [list(box.dim) for box in boxtype.permuted_boxes] self.assertEqual(len(permutations), 4) self.assertIn([1, 5, 7], permutations) self.assertIn([5, 1, 7], permutations) self.assertIn([1, 7, 5], permutations) self.assertIn([7, 1, 5], permutations)
def test_all_orientations(self): boxtype = clp.BoxType(self.dim, (1,1,1)) permutations = [list(box.dim) for box in boxtype.permuted_boxes] self.assertEqual(len(permutations), 6) self.assertIn([1, 5, 7], permutations) self.assertIn([5, 1, 7], permutations) self.assertIn([1, 7, 5], permutations) self.assertIn([7, 1, 5], permutations) self.assertIn([7, 5, 1], permutations) self.assertIn([5, 7, 1], permutations)
def test_split(self): """Normal use case of the method split""" boxtype = clp.BoxType([19, 12, 8], [1, 1, 1]) box = clp.Box([8, 12, 19], boxtype) block = clp.Block(box, [4, 2, 1], self.space) split_space = self.space.split(block) new_spaces = [ clp.Space([5, 28, 0], [32, 3, 24]), clp.Space([5, 4, 19], [32, 24, 5]), clp.Space([37, 4, 0], [10, 27, 24]) ] for i in range(3): self.assertEqual(new_spaces[i], split_space[i])
def __init__(self, *args, **kwargs): super(SpaceTest, self).__init__(*args, **kwargs) self.space = clp.Space([5, 4, 0], [42, 27, 24]) B1 = clp.BoxType([19, 12, 8], [1, 1, 1]) B2 = clp.BoxType([5, 24, 20]) self.cargo = {B1: 8, B2: 4}
def test_too_small_space(self): cargo = {clp.BoxType([40, 30, 5]): 1} blocks = self.space.find_max_blocks(cargo) self.assertListEqual(blocks, [])