Exemplo n.º 1
0
def test_compute_literal_from_client(test, serial, server):
    client.requests = server.app.test_client()
    c = bz.Client('localhost:6363')
    t = symbol('t', c.dshape)
    expr = t.accounts.amount + literal(1000)
    expected = [1100, 1200]
    tdata = compute(expr, c)
    assert list(tdata) == expected
Exemplo n.º 2
0
def test_compute_literal_from_client(test, serial, server):
    client.requests = server.app.test_client()
    c = bz.Client('localhost:6363')
    t = symbol('t', c.dshape)
    expr = t.accounts.amount + literal(1000)
    expected = [1100, 1200]
    tdata = compute(expr, c)
    assert list(tdata) == expected
Exemplo n.º 3
0
def test_to_and_from_tree_with_literal():
    data = frozenset([1, 2])
    expr = literal(data)
    as_tree = {
        'args': [
            frozenset({1, 2}),
            datashape.dshape("2 * int64"),
            None,
        ],
        'op': 'Literal',
    }
    assert to_tree(expr) == as_tree

    assert from_tree(as_tree).isidentical(expr)
Exemplo n.º 4
0
def test_to_and_from_tree_with_literal():
    data = frozenset([1, 2])
    expr = literal(data)
    as_tree = {
        'args': [
            frozenset({1, 2}),
            datashape.dshape("2 * int64"),
            None,
        ],
        'op': 'Literal',
    }
    assert to_tree(expr) == as_tree

    assert from_tree(as_tree).isidentical(expr)
Exemplo n.º 5
0
def test_compute_on_literal_gives_back_data():
    assert compute(literal([1, 2, 3])) == [1, 2, 3]
Exemplo n.º 6
0
from odo import into

from blaze.compute import compute
from blaze.expr import data, literal, symbol


tdata = (('Alice', 100),
         ('Bob', 200))

L = [[1, 'Alice',   100],
     [2, 'Bob',    -200],
     [3, 'Charlie', 300],
     [4, 'Denis',   400],
     [5, 'Edith',  -500]]

l = literal(tdata)
nl = literal(tdata, name='amounts')
t = data(tdata, fields=['name', 'amount'])


def test_resources_fail():
    t = symbol('t', 'var * {x: int, y: int}')
    d = t[t['x'] > 100]
    with pytest.raises(ValueError):
        compute(d)


def test_compute_on_Data_gives_back_data():
    assert compute(data([1, 2, 3])) == [1, 2, 3]