Esempio 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])
Esempio 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,)])
Esempio 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,)])
Esempio 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,)])
Esempio 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,)])
Esempio 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)])
Esempio 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'])
Esempio 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}])
Esempio 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},)])
Esempio 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])
Esempio 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,)])
Esempio 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,)])
Esempio 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])
Esempio 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,)])
Esempio 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)])
Esempio 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])
Esempio 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)])
Esempio 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,)])
Esempio 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,)])
Esempio 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])
Esempio 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])
Esempio 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,)])
Esempio 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'])
Esempio 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,)])
Esempio 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])
Esempio 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,)])
Esempio 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])
Esempio 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])
Esempio 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)])
Esempio 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,)])