Ejemplo n.º 1
0
 def test_more_things(self):
     self.assertSequenceEqual(
         [slice(0, None, 3),
          slice(1, None, 3),
          slice(2, None, 3)],
         list(tags.gen_batch_slices(10, 4)),
     )
Ejemplo n.º 2
0
 def test_batches_by_brute_force(self):
     expected = list(range(99))
     for size in range(1, len(expected) // 2):
         slices = tags.gen_batch_slices(len(expected), size)
         batches = list(expected[sl] for sl in slices)
         # Every element in the original list is present in the
         # reconsolidated list.
         observed = sorted(chain.from_iterable(batches))
         self.assertSequenceEqual(expected, observed)
         # The longest batch is never more than 1 element longer
         # than the shortest batch.
         lens = [len(batch) for batch in batches]
         self.assertIn(max(lens) - min(lens), (0, 1))
Ejemplo n.º 3
0
 def test_one_thing(self):
     self.assertSequenceEqual([slice(0, None, 1)],
                              list(tags.gen_batch_slices(1, 4)))
Ejemplo n.º 4
0
 def test_no_things(self):
     self.assertSequenceEqual([], list(tags.gen_batch_slices(0, 4)))