Exemple #1
0
 def test_chunk(self):
     # Assert list chunk (near-)equal size.
     for a, n, b in (
       ([1,2,3,4,5], 0, []),
       ([1,2,3,4,5], 1, [[1,2,3,4,5]]),
       ([1,2,3,4,5], 2, [[1,2,3], [4,5]]),
       ([1,2,3,4,5], 3, [[1,2], [3,4], [5]]),
       ([1,2,3,4,5], 4, [[1,2], [3], [4], [5]]),
       ([1,2,3,4,5], 5, [[1], [2], [3], [4], [5]]),
       ([1,2,3,4,5], 6, [[1], [2], [3], [4], [5], []])):
         self.assertEqual(list(vector.chunk(a, n)), b)
     print("pattern.vector.chunk()")
Exemple #2
0
 def test_chunk(self):
     # Assert list chunk (near-)equal size.
     for a, n, b in (
             ([1, 2, 3, 4, 5], 0, []),
             ([1, 2, 3, 4, 5], 1, [[1, 2, 3, 4, 5]]),
             ([1, 2, 3, 4, 5], 2, [[1, 2, 3], [4, 5]]),
             ([1, 2, 3, 4, 5], 3, [[1, 2], [3, 4], [5]]),
             ([1, 2, 3, 4, 5], 4, [[1, 2], [3], [4], [5]]),
             ([1, 2, 3, 4, 5], 5, [[1], [2], [3], [4], [5]]),
             ([1, 2, 3, 4, 5], 6, [[1], [2], [3], [4], [5], []])):
         self.assertEqual(list(vector.chunk(a, n)), b)
     print("pattern.vector.chunk()")