コード例 #1
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_no_pad(self):
     xform = xf.partition(2)
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4, 5])),
                      [(1, 2), (3, 4)])
コード例 #2
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_no_pad_empty(self):
     xform = xf.partition(2)
     self.assertEqual(list(xf.xiter(xform, [])), [])
コード例 #3
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_reduced_last_element(self):
     xform = xf.comp(xf.partition(3, 3, ['pad', 'pad']), xf.take(2))
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])),
                      [(1, 2, 3), (4, 'pad', 'pad')])
コード例 #4
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_complete(self):
     xform = xf.comp(xf.partition(2), xf.partition_all(10))
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])),
                      [((1, 2), (3, 4),)])
コード例 #5
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_pad_with_iterator(self):
     xform = xf.partition(3, 3, iter(['pad', 'pad']))
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])),
                      [(1, 2, 3), (4, 'pad', 'pad')])
コード例 #6
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_pad_too_large(self):
     xform = xf.partition(3, 3, ['pad'] * 5)
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3, 4])),
                      [(1, 2, 3), (4, 'pad', 'pad')])
コード例 #7
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_pad_not_iter(self):
     with self.assertRaises(TypeError):
         xform = xf.partition(2, 2, 1)
         list(xf.xiter(xform, [1, 2, 3]))
コード例 #8
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_step_neg(self):
     with self.assertRaises(ValueError):
         xf.partition(1, -1)
コード例 #9
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_step_zero(self):
     with self.assertRaises(ValueError):
         xf.partition(1, 0)
コード例 #10
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_step_fraction(self):
     with self.assertRaises(ValueError):
         xf.partition(1, 1.5)
コード例 #11
0
ファイル: test_transducers.py プロジェクト: jmagers/chanpy
 def test_step_pos(self):
     xform = xf.partition(2, 1)
     self.assertEqual(list(xf.xiter(xform, [1, 2, 3])), [(1, 2), (2, 3)])