コード例 #1
0
ファイル: toolz-test.py プロジェクト: wfelipe3/learning
def test_nth():
    l = list([1, 2, 3])
    i = iter([1, 2, 3])
    assert_that(nth(2, l)).is_equal_to(3)
    assert_that(nth(2, l)).is_equal_to(3)
    assert_that(nth(2, i)).is_equal_to(3)  #Can do only once for the iter
    assert_that(last(l)).is_equal_to(nth(len(l) - 1, l))
コード例 #2
0
ファイル: test_itertoolz.py プロジェクト: zhouyujoe/toolz
def test_nth():
    assert nth(2, 'ABCDE') == 'C'
    assert nth(2, iter('ABCDE')) == 'C'
    assert nth(1, (3, 2, 1)) == 2
    assert nth(0, {'foo': 'bar'}) == 'foo'
    assert raises(StopIteration, lambda: nth(10, {10: 'foo'}))
    assert nth(-2, 'ABCDE') == 'D'
    assert raises(ValueError, lambda: nth(-2, iter('ABCDE')))
コード例 #3
0
ファイル: test_itertoolz.py プロジェクト: caioaao/toolz
def test_nth():
    assert nth(2, 'ABCDE') == 'C'
    assert nth(2, iter('ABCDE')) == 'C'
    assert nth(1, (3, 2, 1)) == 2
    assert nth(0, {'foo': 'bar'}) == 'foo'
    assert raises(StopIteration, lambda: nth(10, {10: 'foo'}))
    assert nth(-2, 'ABCDE') == 'D'
    assert raises(ValueError, lambda: nth(-2, iter('ABCDE')))
コード例 #4
0
ファイル: result.py プロジェクト: mrgriffin/market-dsl
 def nth(expr, env):
     try:
         return nth(expr.n, eval(expr.coll, env))
     except StopIteration:
         return None
コード例 #5
0
ファイル: consensus.py プロジェクト: VDBWRAIR/bioframes
def gap_fill_ref(original_ref, new_ref, pileup_positions, offs, off_pos, off):
    raw_missings =  set(xrange(1, len(original_ref)+1)) - set(pileup_positions)
    missings = reduce(drop_gaps_because_insertion_offsets, izip(offs, off_pos), raw_missings)
    gap_filled = reduce(insert_gap, imap(lambda x: x - 1, missings),  new_ref)
    return nth(off, iterate(lambda s: s[:-1] if s[-1] == '-' else s, gap_filled))