def test_complete(self): result = xf.itransduce(xf.partition_all(2), xf.append, [1, 2, 3]) self.assertEqual(result, [(1, 2), (3,)])
def test_itransduce_init_only_complete(self): def xform(rf): return lambda result: rf(result + 100) result = xf.itransduce(xform, xf.identity, 1, []) self.assertEqual(result, 101)
def test_itransduce_reduced(self): result = xf.itransduce(xf.take(2), sum_rf, 1, [2, 3, 100]) self.assertEqual(result, 6)
def test_itransduce_init_only(self): result = xf.itransduce(xf.filter(None), xf.identity, 1, []) self.assertEqual(result, 1)
def test_itransduce_empty_no_init_no_arity_zero(self): with self.assertRaises(TypeError): xf.itransduce(xf.filter(lambda x: x % 2 == 0), lambda x, y: x + y, [])
def test_itransduce_empty_no_init(self): result = xf.itransduce(xf.filter(lambda x: x % 2 == 0), sum_rf, []) self.assertEqual(result, 0)
def test_itransduce_some_no_init(self): result = xf.itransduce(xf.filter(lambda x: x % 2 == 0), sum_rf, [1, 2, 3, 8]) self.assertEqual(result, 10)
def test_itransduce_some(self): result = xf.itransduce(xf.filter(lambda x: x % 2 == 0), sum_rf, 1, [2, 3, 8]) self.assertEqual(result, 11)