Ejemplo n.º 1
0
 def test_batch(self):
     self.assertSequenceEqual(
         utils.batch(2, range(10)),
         [range(0, 2),
          range(2, 4),
          range(4, 6),
          range(6, 8),
          range(8, 10)])
     self.assertEqual(utils.batch(3, [429, 5, 2, 14, 42, 132, 1, 1]),
                      [[429, 5, 2], [14, 42, 132], [1, 1]])
     self.assertEqual(
         utils.batch(4, range(10)),
         [range(0, 4), range(4, 8), range(8, 10)])
Ejemplo n.º 2
0
def matrix(ncol, *args):
    return np.array(utils.batch(ncol, args))
Ejemplo n.º 3
0
 def testbatch(self):
     self.assertEqual(utils.batch(3, [429, 5, 2, 14, 42, 132, 1, 1]), [[429, 5, 2], [14, 42, 132], [1, 1]])
     self.assertEqual(utils.batch(4, range(10)), [range(0, 4), range(4, 8), range(8, 10)])