Ejemplo n.º 1
0
 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])
Ejemplo n.º 2
0
 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,)])
Ejemplo n.º 3
0
 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,)])
Ejemplo n.º 4
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,)])
Ejemplo n.º 5
0
 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,)])
Ejemplo n.º 6
0
 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)])
Ejemplo n.º 7
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'])
Ejemplo n.º 8
0
 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}])
Ejemplo n.º 9
0
 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},)])
Ejemplo n.º 10
0
 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])
Ejemplo n.º 11
0
 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,)])
Ejemplo n.º 12
0
 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,)])
Ejemplo n.º 13
0
 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])
Ejemplo n.º 14
0
 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,)])
Ejemplo n.º 15
0
 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)])
Ejemplo n.º 16
0
 def test_reduced(self):
     xform = xf.comp(xf.cat, xf.take(2))
     self.assertEqual(list(xf.xiter(xform, [[1, 2], [3]])), [1, 2])
Ejemplo n.º 17
0
 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)])
Ejemplo n.º 18
0
 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,)])
Ejemplo n.º 19
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,)])
Ejemplo n.º 20
0
 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])
Ejemplo n.º 21
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])
Ejemplo n.º 22
0
 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,)])
Ejemplo n.º 23
0
 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'])
Ejemplo n.º 24
0
 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,)])
Ejemplo n.º 25
0
 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])
Ejemplo n.º 26
0
 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,)])
Ejemplo n.º 27
0
 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])
Ejemplo n.º 28
0
 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])
Ejemplo n.º 29
0
 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)])
Ejemplo n.º 30
0
 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,)])