예제 #1
0
def test_table_resource():
    with tmpfile('csv') as filename:
        csv = CSV(filename, 'w', schema='{x: int, y: int}')
        csv.extend([[1, 2], [10, 20]])

        t = Table(filename)
        assert isinstance(t.data, CSV)
        assert list(compute(t)) == list(csv)
예제 #2
0
def test_compute():
    assert list(compute(t['amount'] + 1)) == [101, 201]
예제 #3
0
def test_compute():
    assert compute(t) == data
예제 #4
0
def test_resources_fail():
    t = TableSymbol('t', '{x:int, y:int}')
    d = t[t['x'] > 100]
    with pytest.raises(ValueError):
        compute(d)
예제 #5
0
def test_into_nd_array_column_failure():
    tble = Table(L, columns=['id', 'name', 'balance'])
    expr = tble[tble['balance'] < 0]
    colarray = into(nd.array, expr)
    assert len(list(compute(expr))) == len(colarray)
예제 #6
0
def test_into_nd_array_selection():
    tble = Table(L, columns=['id', 'name', 'balance'])
    expr = tble[tble['balance'] < 0]
    selarray = into(nd.array, expr)
    assert len(list(compute(expr))) == len(selarray)
예제 #7
0
def test_into_np_ndarray_column():
    tble = Table(L, columns=['id', 'name', 'balance'])
    expr = tble[tble['balance'] < 0]['name']
    colarray = into(np.ndarray, expr)
    assert len(list(compute(expr))) == len(colarray)