コード例 #1
0
ファイル: test_selects.py プロジェクト: talwai/petl
def test_selectusingcontext():

    table1 = (("foo", "bar"), ("A", 1), ("B", 4), ("C", 5), ("D", 9))

    expect = (("foo", "bar"), ("B", 4), ("C", 5))

    def query(prv, cur, nxt):
        return (prv is not None and (cur.bar - prv.bar) < 2) or (nxt is not None and (nxt.bar - cur.bar) < 2)

    actual = selectusingcontext(table1, query)
    ieq(expect, actual)
    ieq(expect, actual)
コード例 #2
0
ファイル: test_selects.py プロジェクト: viktor-evdokimov/petl
def test_selectusingcontext():

    table1 = (('foo', 'bar'), ('A', 1), ('B', 4), ('C', 5), ('D', 9))

    expect = (('foo', 'bar'), ('B', 4), ('C', 5))

    def query(prv, cur, nxt):
        return ((prv is not None and (cur.bar - prv.bar) < 2)
                or (nxt is not None and (nxt.bar - cur.bar) < 2))

    actual = selectusingcontext(table1, query)
    ieq(expect, actual)
    ieq(expect, actual)
コード例 #3
0
ファイル: test_selects.py プロジェクト: DeanWay/petl
def test_selectusingcontext():

    table1 = (('foo', 'bar'),
              ('A', 1),
              ('B', 4),
              ('C', 5),
              ('D', 9))

    expect = (('foo', 'bar'),
              ('B', 4),
              ('C', 5))

    def query(prv, cur, nxt):
        return ((prv is not None and (cur.bar - prv.bar) < 2)
                or (nxt is not None and (nxt.bar - cur.bar) < 2))

    actual = selectusingcontext(table1, query)
    ieq(expect, actual)
    ieq(expect, actual)