Example #1
0
def test_lean_by_with_summary():
    assert lean_projection(by(t.x, total=t.y.sum()))._child.isidentical(t[["x", "y"]])

    tt = t[["x", "y"]]
    result = lean_projection(by(t.x, a=t.y.sum(), b=t.z.sum())[["x", "a"]])
    expected = Projection(By(Field(tt, "x"), summary(a=sum(Field(tt, "y")))), ("x", "a"))
    assert result.isidentical(expected)
Example #2
0
def test_lean_by_with_summary():
    assert lean_projection(by(t.x, total=t.y.sum()))._child.isidentical(
        t[['x', 'y']])

    tt = t[['x', 'y']]
    result = lean_projection(by(t.x, a=t.y.sum(), b=t.z.sum())[['x', 'a']])
    expected = Projection(By(Field(tt, 'x'), summary(a=sum(Field(tt, 'y')))),
                          ('x', 'a'))
    assert result.isidentical(expected)
Example #3
0
def test_lean_by_with_summary():
    assert lean_projection(by(t.x, total=t.y.sum()))._child.isidentical(
                    t[['x', 'y']])

    tt = t[['x', 'y']]
    result = lean_projection(by(t.x, a=t.y.sum(), b=t.z.sum())[['x', 'a']])
    expected = Projection(
                    By(Field(tt, 'x'), summary(a=sum(Field(tt, 'y')))),
                    ('x', 'a'))
    assert result.isidentical(expected)
Example #4
0
def test_merge():
    expr = lean_projection(merge(a=t.x + 1, y=t.y))
    assert expr._child.isidentical(t[['x', 'y']])
Example #5
0
def test_distinct():
    expr = t.distinct()[['x', 'y']]
    assert lean_projection(expr).isidentical(expr)
Example #6
0
def test_sort():
    assert lean_projection(t.sort('x').y).isidentical(t[['x','y']].sort('x').y)
Example #7
0
def test_lean_projection_by():
    assert lean_projection(by(t.x, t.y.sum()))._child.isidentical(
                    t[['x', 'y']])
Example #8
0
File: bcolz.py Project: vitan/blaze
def optimize(expr, _):
    return lean_projection(expr)
Example #9
0
def test_distinct():
    expr = t.distinct()[['x', 'y']]
    assert lean_projection(expr).isidentical(expr)
Example #10
0
def test_merge_with_table():
    expr = lean_projection(merge(t, a=t.x + 1))
    assert expr.isidentical(expr)  # wut?
Example #11
0
def test_merge():
    expr = lean_projection(merge(a=t.x + 1, y=t.y))
    assert expr._child.isidentical(t[["x", "y"]])
Example #12
0
def test_sort():
    assert lean_projection(t.sort("x").y).isidentical(t[["x", "y"]].sort("x").y)
Example #13
0
def test_lean_projection_by():
    assert lean_projection(by(t.x, total=t.y.sum()))._child.isidentical(t[["x", "y"]])
Example #14
0
def test_lean_projection():
    assert lean_projection(t[t.x > 0].y)._child._child.isidentical(t[["x", "y"]])
Example #15
0
def test_like():
    t = symbol('t', 'var * {name: string, x: int, y: int}')
    expr = t.like(name='Alice').y

    result = lean_projection(expr)
    assert result._child._child.isidentical(t[['name', 'y']])
Example #16
0
def test_merge_with_table():
    expr = lean_projection(merge(t, a=t.x + 1))
    assert expr.isidentical(expr)
Example #17
0
def test_elemwise_thats_also_a_column():
    t = symbol('t', 'var * {x: int, time: datetime, y: int}')
    expr = t[t.x > 0].time.truncate(months=1)
    expected = t[['time', 'x']]
    result = lean_projection(expr)
    assert result._child._child._child.isidentical(t[['time', 'x']])
Example #18
0
def test_head():
    assert lean_projection(t.sort("x").y.head(5)).isidentical(t[["x", "y"]].sort("x").y.head(5))
Example #19
0
def test_like():
    t = symbol('t', 'var * {name: string, x: int, y: int}')
    expr = t[t.name.like('Alice')].y

    result = lean_projection(expr)
    assert result._child._child.isidentical(t[['name', 'y']])
Example #20
0
def test_elemwise_thats_also_a_column():
    t = symbol("t", "var * {x: int, time: datetime, y: int}")
    expr = t[t.x > 0].time.truncate(months=1)
    expected = t[["time", "x"]]
    result = lean_projection(expr)
    assert result._child._child._child.isidentical(expected)
Example #21
0
def test_lean_projection():
    assert lean_projection(t[t.x > 0].y)._child._child.isidentical(t[['x', 'y']])
Example #22
0
def test_distinct():
    expr = t.distinct()[["x", "y"]]
    assert lean_projection(expr).isidentical(expr)
Example #23
0
def test_like():
    t = symbol("t", "var * {name: string, x: int, y: int}")
    expr = t[t.name.like("Alice")].y
    result = lean_projection(expr)
    assert result._child._child.isidentical(t[["name", "y"]])
Example #24
0
File: bcolz.py Project: vitan/blaze
def optimize(expr, _):
    return lean_projection(expr)
Example #25
0
def test_head():
    assert lean_projection(t.sort('x').y.head(5)).isidentical(
                t[['x','y']].sort('x').y.head(5))
Example #26
0
def test_elemwise_thats_also_a_column():
    t = symbol('t', 'var * {x: int, time: datetime, y: int}')
    expr = t[t.x > 0].time.truncate(months=1)
    expected = t[['time', 'x']]
    result = lean_projection(expr)
    assert result._child._child._child.isidentical(t[['time', 'x']])