コード例 #1
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 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,)])
コード例 #2
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 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])
コード例 #3
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_arity_zero(self):
     self.assertEqual(xf.reductions(xf.identity, 1)(lambda: 'success')(),
                      'success')
コード例 #4
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 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])
コード例 #5
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 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'])
コード例 #6
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 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,)])
コード例 #7
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_reductions_init_only(self):
     xform = xf.reductions(lambda x, y: x + y, 'success')
     self.assertEqual(list(xf.xiter(xform, [])), ['success'])
コード例 #8
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 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])