def test_max_spare_cap_few(self): h = rb.MaxSpareCapacity(self.bins[:4]) expected = [[8], [5, 2, 1], [7], [6, 4]] misfits = [] self.assertEqual(len(self.items) - len(misfits), h.binpack(self.items)) did_part = [bin.items for bin in h.bins] self.assertEqual(expected, did_part) self.assertEqual(misfits, h.misfits)
def test_max_spare_cap_small(self): h = rb.MaxSpareCapacity(make_bin=lambda: self.make_bin(7)) expected = [[5, 2], [7], [6], [4, 1]] misfits = [8] self.assertEqual(len(self.items) - len(misfits), h.binpack(self.items)) did_part = [bin.items for bin in h.bins] self.assertEqual(expected, did_part) self.assertEqual(misfits, h.misfits)
def test_max_spare_cap_make(self): h = rb.MaxSpareCapacity(make_bin=lambda: self.make_bin(10)) self.assertEqual(len(self.items), h.binpack(self.items)) expected = [[8], [5, 2, 1], [7], [6, 4]] did_part = [bin.items for bin in h.bins] self.assertEqual(expected, did_part)
def test_max_spare_cap_fixed(self): h = rb.MaxSpareCapacity(self.bins) self.assertEqual(len(self.items), h.binpack(self.items)) expected = [[8], [5, 1], [7], [6], [2, 4]] did_part = [bin.items for bin in h.bins] self.assertEqual(expected, did_part)