Example #1
0
    def test_split_even_size_chunks(self):
        chunks = chunk_array([1, 2, 3, 4], 2)
        self.assertEqual(chunks, [[1, 2], [3, 4]])

        chunks = chunk_array([1, 2, 3, 4, 5, 6, 7, 8, 9], 2)
        self.assertEqual(chunks, [[1, 2, 3, 4, 5], [6, 7, 8, 9]])

        chunks = chunk_array([1, 2, 3, 4, 5, 6, 7, 8, 9], 3)
        self.assertEqual(chunks, [[1, 2, 3], [4, 5, 6], [7, 8, 9]])
Example #2
0
 def test_spilt_into_too_many_chunks(self):
     with self.assertRaises(AssertionError):
         chunk_array([1, 2, 3, 4], 7)
Example #3
0
 def test_split_into_one_chunk(self):
     chunks = chunk_array([1, 2, 3, 4, 5, 6, 7], 7)
     self.assertEqual(chunks, [[1, 2, 3, 4, 5, 6, 7]])
Example #4
0
 def test_split_into_no_chunks(self):
     with self.assertRaises(AssertionError):
         chunk_array([1, 2, 3], 0)
Example #5
0
    def test_split_chunks_with_remainder(self):
        chunks = chunk_array([1, 2, 3, 4, 5], 3)
        self.assertEqual(chunks, [[1, 2], [3, 4], [5]])

        chunks = chunk_array([1, 2, 3, 4, 5], 2)
        self.assertEqual(chunks, [[1, 2, 3], [4, 5]])