def test_recursive_rowfunc(): f = rrowfunc(t['name'], t) assert [f(row) for row in data] == [row[0] for row in data] expr = optimize(t['amount'] + t['id'], []) f = rrowfunc(expr, t) assert [f(row) for row in data] == [row[1] + row[2] for row in data] assert raises(Exception, lambda: rrowfunc(t[t['amount'] < 0]['name'], t))
def test_neg(): expr = optimize(-t.amount, []) assert list(compute(expr, data)) == [-x[1] for x in data]
def test_dispatched_rowfunc(): cw = optimize(t['amount'] + 100, []) assert rowfunc(t)(t) == t assert rowfunc(cw)(('Alice', 100, 1)) == 200