예제 #1
0
 def testShelfBWFRotation(self):
     """
     Best Bin Fit
     Shelf Bins (best_width_fit)
     Item Sorting == False
     Item Rotation == True
     """
     M = binpack.BinManager(10, 5,
                            pack_algo='shelf',
                            bin_algo="bin_first_fit",
                            sorting=False,
                            rotation=True)
     ITEM = binpack.Item(1, 1)
     ITEM2 = binpack.Item(4, 3)
     ITEM3 = binpack.Item(2, 2)
     M.add_items(ITEM, ITEM2, ITEM3)
     M.execute()
     correct = [ITEM, ITEM2, ITEM3]
     with self.subTest():
         self.assertEqual(M.items, correct)
     with self.subTest():
         self.assertEqual(ITEM.CornerPoint, (0,0))
     with self.subTest():
         self.assertEqual(ITEM2.CornerPoint, (0,1))
     with self.subTest():
         self.assertEqual(ITEM3.CornerPoint, (4,1))
예제 #2
0
 def testGuillotineBWFRotation(self):
     """
     Bin First Fit
     Guillotine Bins (best_width_fit)
     Split Horizontal
     Item Sorting == False
     Item Rotation == True
     """
     M = binpack.BinManager(10, 5,
                            pack_algo='guillotine',
                            bin_algo="bin_first_fit",
                            sorting=False,
                            rotation=True)
     ITEM = binpack.Item(4, 3)
     ITEM2 = binpack.Item(6, 5)
     ITEM3 = binpack.Item(4, 4)
     M.add_items(ITEM, ITEM2, ITEM3)
     M.execute()
     correct = [ITEM, ITEM2, ITEM3]
     with self.subTest():
         self.assertEqual(M.items, correct)
     with self.subTest():
         self.assertEqual(ITEM.CornerPoint, (0,0))
     with self.subTest():
         self.assertEqual(ITEM2.CornerPoint, (0,0))
     with self.subTest():
         self.assertEqual(ITEM3.CornerPoint, (6,0))
예제 #3
0
 def testReadme(self):
     """
     Example insertion from README.md
     """
     M = binpack.BinManager(8, 4, pack_algo='shelf')
     ITEM = binpack.Item(4, 2)
     ITEM2 = binpack.Item(5, 2)
     ITEM3 = binpack.Item(2, 2)
     M.add_items(ITEM, ITEM2, ITEM3)
     M.execute()
     correct = [ITEM2, ITEM, ITEM3]
     with self.subTest():
         self.assertEqual(M.items, correct)
     with self.subTest():
         self.assertEqual(ITEM.CornerPoint, (0,2))
     with self.subTest():
         self.assertEqual(ITEM2.CornerPoint, (0,0))
     with self.subTest():
         self.assertEqual(ITEM3.CornerPoint, (5,0))
예제 #4
0
 def testGuillotineBWFSortingRotation(self):
     """
     Best Bin Fit
     Guillotine Bins (best_width_fit)
     Split Horizontal
     Item Sorting == True
     Item Rotation == True
     """
     M = binpack.BinManager(10, 5, pack_algo='guillotine',
                            sorting=True, rotation=True)
     ITEM = binpack.Item(3, 4)
     ITEM2 = binpack.Item(5, 3)
     ITEM3 = binpack.Item(2, 2)
     M.add_items(ITEM, ITEM2, ITEM3)
     M.execute()
     correct = [ITEM2, ITEM, ITEM3]
     with self.subTest():
         self.assertEqual(M.items, correct)
     with self.subTest():
         self.assertEqual(ITEM.CornerPoint, (5,0))
     with self.subTest():
         self.assertEqual(ITEM2.CornerPoint, (0,0))
     with self.subTest():
         self.assertEqual(ITEM3.CornerPoint, (0,3))