def test_reduced(self): xform = xf.comp(xf.remove(lambda x: x % 2 == 0), xf.take(2)) self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4, 5])), [1, 3])
def test_complete(self): xform = xf.comp(xf.replace({1: 'one'}), xf.partition_all(2)) self.assertEqual(list(xf.xiter(xform, [1, 2, 3])), [('one', 2), (3,)])
def test_complete(self): xform = xf.comp(xf.random_sample(1), xf.partition_all(2)) self.assertEqual(list(xf.xiter(xform, [1, 2, 3])), [(1, 2), (3,)])
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_complete(self): xform = xf.comp(xf.interpose('s'), xf.partition_all(2)) self.assertEqual(list(xf.xiter(xform, [1, 2])), [(1, 's'), (2,)])
def test_complete(self): xform = xf.comp(xf.partition_by(lambda x: x % 2 == 0), xf.take(2)) self.assertEqual(list(xf.xiter(xform, [2, 4, 6, 1, 3, 5, 8])), [(2, 4, 6), (1, 3, 5)])
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_reduced(self): xform = xf.comp(xf.keep_indexed(self.even_set), xf.take(2)) self.assertEqual(list(xf.xiter(xform, [2, 3, 4, 5, 6])), [{2}, {4}])
def test_complete(self): xform = xf.comp(xf.keep_indexed(self.even_set), xf.partition_all(2)) self.assertEqual(list(xf.xiter(xform, [2, 4, 5, 6])), [({2}, {4}), ({6},)])
def test_reduced(self): xform = xf.comp(xf.keep(lambda x: x if x % 2 == 0 else None), xf.take(2)) self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4, 5, 6])), [2, 4])
def test_complete(self): xform = xf.comp(xf.keep(lambda x: x if x % 2 == 0 else None), xf.partition_all(2)) self.assertEqual(list(xf.xiter(xform, [2, 4, 5, 6])), [(2, 4), (6,)])
def test_complete(self): xform = xf.comp(xf.remove_indexed(self.even_i_pos_v), xf.partition_all(2)) self.assertEqual(list(xf.xiter(xform, [1, 2, -3, 4, 5])), [(2, -3), (4,)])
def test_reduced(self): xform = xf.comp(xf.remove_indexed(self.even_i_pos_v), xf.take(1)) self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])), [2])
def test_complete(self): xform = xf.comp(xf.remove(lambda x: x % 2 == 0), xf.partition_all(2)) self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 5])), [(1, 3), (5,)])
def test_reduced_with_step(self): xform = xf.comp(xf.partition_all(2, 1), xf.take(1)) self.assertEqual(list(xf.xiter(xform, [1, 2, 3])), [(1, 2)])
def test_reduced(self): xform = xf.comp(xf.cat, xf.take(2)) self.assertEqual(list(xf.xiter(xform, [[1, 2], [3]])), [1, 2])
def test_reduced(self): xform = xf.comp(xf.partition_by(lambda x: x % 2 == 0), xf.take(2)) self.assertEqual(list(xf.xiter(xform, [1, 3, 2, 4, 5, 7])), [(1, 3), (2, 4)])
def test_complete(self): xform = xf.comp(xf.cat, xf.partition_all(2)) self.assertEqual(list(xf.xiter(xform, [[1, 2], [3]])), [(1, 2), (3,)])
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_reduced(self): xform = xf.comp(xf.mapcat(lambda x: [x, x * 2]), xf.take(3)) self.assertEqual(list(xf.xiter(xform, [1, 4, 16])), [1, 2, 4])
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_complete(self): xform = xf.comp(xf.mapcat(lambda x: [x, x * 2, x * 3]), xf.partition_all(2)) self.assertEqual(list(xf.xiter(xform, [1])), [(1, 2), (3,)])
def test_reduced(self): xform = xf.comp(xf.interpose('s'), xf.take(4)) self.assertEqual(list(xf.xiter(xform, [1, 2, 3])), [1, 's', 2, 's'])
def test_reduced_without_step(self): xform = xf.comp(xf.partition_all(1), xf.take(2)) self.assertEqual(list(xf.xiter(xform, range(12))), [(0,), (1,)])
def test_reduced(self): xform = xf.comp(xf.replace({1: 'one'}), xf.take(2)) self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])), ['one', 2])
def test_complete(self): xform = xf.comp(xf.distinct, xf.partition_all(2)) self.assertEqual(list(xf.xiter(xform, [1, 2, 1, 2, 3, 3])), [(1, 2), (3,)])
def test_reduced(self): xform = xf.comp(xf.random_sample(1), xf.take(2)) self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])), [1, 2])
def test_reduced(self): xform = xf.comp(xf.dedupe, xf.take(2)) self.assertEqual(list(xf.xiter(xform, [1, 1, 2, 2, 3, 4])), [1, 2])
def test_partition_with_smaller_step_reduced_during_complete(self): xform = xf.comp(xf.partition_all(3, 1), xf.take(4)) self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4, 5])), [(1, 2, 3), (2, 3, 4), (3, 4, 5), (4, 5)])
def test_complete(self): xform = xf.comp(xf.filter_indexed(self.even_i_pos_v), xf.partition_all(2)) self.assertEqual(list(xf.xiter(xform, [-1, 2, 3, 4, 5, 6, 7])), [(3, 5), (7,)])