示例#1
0
 def test_complete(self):
     xform = xf.comp(xf.reductions(lambda x, y: x + y, 1),
                     xf.partition_all(2))
     self.assertEqual(list(xf.xiter(xform, [2, 3])), [(1, 3), (6,)])
示例#2
0
 def test_reductions_reduced(self):
     xform = xf.comp(xf.reductions(lambda x, y: x + y, 1), xf.take(3))
     self.assertEqual(list(xf.xiter(xform, [2, 3, 4, 5])), [1, 3, 6])
示例#3
0
 def test_arity_zero(self):
     self.assertEqual(xf.reductions(xf.identity, 1)(lambda: 'success')(),
                      'success')
示例#4
0
 def test_reductions_no_init(self):
     xform = xf.reductions(xf.multi_arity(lambda: 100, None, sum_rf))
     self.assertEqual(list(xf.xiter(xform, [1, 2])), [100, 101, 103])
示例#5
0
 def test_reductions_init_only_reduced(self):
     xform = xf.comp(xf.reductions(lambda x, y: x + y, 'success'),
                     xf.take(1))
     self.assertEqual(list(xf.xiter(xform, [])), ['success'])
示例#6
0
 def test_reductions_init_only_complete(self):
     xform = xf.comp(xf.reductions(lambda x, y: x + y, [1, 2, 3]),
                     xf.cat,
                     xf.partition_all(2))
     self.assertEqual(list(xf.xiter(xform, [])), [(1, 2), (3,)])
示例#7
0
 def test_reductions_init_only(self):
     xform = xf.reductions(lambda x, y: x + y, 'success')
     self.assertEqual(list(xf.xiter(xform, [])), ['success'])
示例#8
0
 def test_reductions_some(self):
     xform = xf.reductions(lambda x, y: x + y, 1)
     self.assertEqual(list(xf.xiter(xform, [2, 3])), [1, 3, 6])