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,)])
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])
def test_arity_zero(self): self.assertEqual(xf.reductions(xf.identity, 1)(lambda: 'success')(), 'success')
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])
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'])
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,)])
def test_reductions_init_only(self): xform = xf.reductions(lambda x, y: x + y, 'success') self.assertEqual(list(xf.xiter(xform, [])), ['success'])
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])