Esempio n. 1
0
def test_sort():
    t = TableSymbol('t', '{name: string, amount: int32, id: int32}')
    s = t.sort('amount', ascending=True)
    print(str(s))
    assert eval(str(s)).isidentical(s)

    assert s.schema == t.schema

    assert t['amount'].sort().key == 'amount'
Esempio n. 2
0
def test_sort():
    t = TableSymbol('t', '{name: string, amount: int32, id: int32}')
    s = t.sort('amount', ascending=True)
    print(str(s))
    assert eval(str(s)).isidentical(s)

    assert s.schema == t.schema

    assert t['amount'].sort().key == 'amount'
Esempio n. 3
0
def test_length():
    t = TableSymbol('t', '10 * {name: string, amount: int}')
    assert t.dshape == dshape('10 * {name: string, amount: int}')
    assert len(t) == 10
    assert len(t.name) == 10
    assert len(t[['name']]) == 10
    assert len(t.sort('name')) == 10
    assert len(t.head(5)) == 5
    assert len(t.head(50)) == 10
Esempio n. 4
0
def test_sort():
    t = TableSymbol("t", "{name: string, amount: int32, id: int32}")
    s = t.sort("amount", ascending=True)
    print(str(s))
    assert eval(str(s)).isidentical(s)

    assert s.schema == t.schema

    assert t["amount"].sort().key == "amount"
Esempio n. 5
0
def test_length():
    t = TableSymbol('t', '10 * {name: string, amount: int}')
    s = TableSymbol('s', '{name:string, amount:int}')
    assert t.dshape == dshape('10 * {name: string, amount: int}')
    assert len(t) == 10
    assert len(t.name) == 10
    assert len(t[['name']]) == 10
    assert len(t.sort('name')) == 10
    assert len(t.head(5)) == 5
    assert len(t.head(50)) == 10
    with pytest.raises(ValueError):
        len(s)
Esempio n. 6
0
def test_length():
    t = TableSymbol('t', '10 * {name: string, amount: int}')
    s = TableSymbol('s', '{name:string, amount:int}')
    assert t.dshape == dshape('10 * {name: string, amount: int}')
    assert len(t) == 10
    assert len(t.name) == 10
    assert len(t[['name']]) == 10
    assert len(t.sort('name')) == 10
    assert len(t.head(5)) == 5
    assert len(t.head(50)) == 10
    with pytest.raises(ValueError):
        len(s)
Esempio n. 7
0
def test_length():
    t = TableSymbol("t", "10 * {name: string, amount: int}")
    s = TableSymbol("s", "{name:string, amount:int}")
    assert t.dshape == dshape("10 * {name: string, amount: int}")
    assert len(t) == 10
    assert len(t.name) == 10
    assert len(t[["name"]]) == 10
    assert len(t.sort("name")) == 10
    assert len(t.head(5)) == 5
    assert len(t.head(50)) == 10
    with pytest.raises(ValueError):
        len(s)
Esempio n. 8
0
def test_improper_selection():
    t = TableSymbol('t', '{x: int, y: int, z: int}')

    assert raises(Exception, lambda: t[t['x'] > 0][t.sort()[t['y' > 0]]])
Esempio n. 9
0
    except pymongo.errors.ConnectionFailure:
        mongo = None

# {expr: [list-of-exclusions]}
expressions = {
        t: [],
        t['id']: [],
        t.id.max(): [],
        t.amount.sum(): [],
        t.amount + 1: [mongo],
        sin(t.amount): [sql, mongo], # sqlite doesn't support trig
        exp(t.amount): [sql, mongo],
        t.amount > 50: [mongo],
        t[t.amount > 50]: [],
        t.like(name='Alic*'): [],
        t.sort('name'): [bc],
        t.sort('name', ascending=False): [bc],
        t.head(3): [],
        t.name.distinct(): [],
        t[t.amount > 50]['name']: [], # odd ordering issue
        t.id.map(lambda x: x + 1, '{id: int}'): [sql, mongo],
        t[t.amount > 50]['name']: [],
        by(t.name, t.amount.sum()): [],
        by(t.id, t.id.count()): [],
        by(t[['id', 'amount']], t.id.count()): [],
        by(t[['id', 'amount']], (t.amount + 1).sum()): [mongo],
        by(t[['id', 'amount']], t.name.nunique()): [mongo],
        by(t.id, t.amount.count()): [],
        by(t.id, t.id.nunique()): [mongo],
        # by(t, t.count()): [],
        # by(t.id, t.count()): [df],
Esempio n. 10
0
def test_improper_selection():
    t = TableSymbol('t', '{x: int, y: int, z: int}')

    assert raises(Exception, lambda: t[t['x'] > 0][t.sort()[t['y' > 0]]])
Esempio n. 11
0
def test_improper_selection():
    t = TableSymbol("t", "{x: int, y: int, z: int}")

    assert raises(Exception, lambda: t[t["x"] > 0][t.sort()[t["y" > 0]]])