def test_batch_array_strlist_with_batch_size_3(self): strlist = [str(i) for i in range(10)] result = predictions.batch_array(strlist, 3) expected = [strlist[:3], strlist[3:6], strlist[6:9], [strlist[9]]] print('result:', result) self.assertEqual(len(expected), len(result)) for i in range(len(expected)): self.assertAllEqual(expected[i], result[i])
def test_batch_array_with_batch_size_3(self): result = predictions.batch_array(TEST_ARRAY, 3) expected = [ TEST_ARRAY[:3, :], TEST_ARRAY[3:6, :], TEST_ARRAY[6:9, :], TEST_ARRAY[9:, :] ] self.assertEqual(len(result), len(expected)) for i in range(len(expected)): self.assertAllEqual(expected[i], result[i])
def test_batch_array_strlist_with_batch_size_none(self): strlist = [str(i) for i in range(10)] result = predictions.batch_array(strlist, None) self.assertEqual(len(result), 1) self.assertAllEqual(result[0], strlist)
def test_batch_array_with_batch_size_15(self): result = predictions.batch_array(TEST_ARRAY, 15) self.assertEqual(len(result), 1) self.assertAllEqual(TEST_ARRAY, result[0])
def test_batch_array_with_batch_size_1(self): result = predictions.batch_array(TEST_ARRAY, 1) self.assertEqual(len(result), 10) for i in range(10): self.assertAllEqual(np.expand_dims(TEST_ARRAY[i, :], 0), result[i])
def test_batch_array_with_none(self): result = predictions.batch_array(TEST_ARRAY, None) self.assertEqual(len(result), 1) self.assertAllEqual(TEST_ARRAY, result[0])