Esempio n. 1
0
def test_client_add_dataset():
    client.requests = test_add  # OMG more monkey patching
    ec = Client('localhost:6363')
    ec.add('iris', example('iris.csv'))
    assert 'iris' in ec.dshape.measure.dict
    iris_data = bz_data(example('iris.csv'))
    assert ec.dshape.measure.dict['iris'] == iris_data.dshape
Esempio n. 2
0
def test_client_add_dataset():
    client.requests = test_add  # OMG more monkey patching
    ec = Client('localhost:6363')
    ec.add('iris', example('iris.csv'))
    assert 'iris' in ec.dshape.measure.dict
    iris_data = bz_data(example('iris.csv'))
    assert ec.dshape.measure.dict['iris'] == iris_data.dshape
Esempio n. 3
0
def test_client_add_dataset_with_args():
    client.requests = test_add  # OMG more monkey patching
    ec = Client('localhost:6363')
    ec.add('teams', 'sqlite:///' + example('teams.db'), 'teams',
           primary_key='teamID')
    assert 'teams' in ec.dshape.measure.dict
    teams_data = bz_data('sqlite:///' + example('teams.db') + '::teams')
    assert ec.dshape.measure.dict['teams'] == teams_data.dshape
Esempio n. 4
0
def test_column(sql):
    t = bz_data(sql)

    r = list(t['x'])
    assert r == [1, 10, 100]
    assert list(t[['x']]) == [(1,), (10,), (100,)]

    assert int(t.count()) == 3
Esempio n. 5
0
def sql():
    data = [(1, 2), (10, 20), (100, 200)]
    sql = bz_data(
        'sqlite:///:memory:::foo',
        dshape='var * {x: int, y: int}',
    )
    into(sql, data)
    return sql
Esempio n. 6
0
def sql():
    data = [(1, 2), (10, 20), (100, 200)]
    sql = bz_data(
        'sqlite:///:memory:::foo',
        dshape='var * {x: int, y: int}',
    )
    into(sql, data)
    return sql
Esempio n. 7
0
def test_expr_client_interactive():
    c = Client('localhost:6363')
    t = bz_data(c)

    assert compute(t.accounts.name) == ['Alice', 'Bob']
    assert (into(set, compute(by(t.accounts.name, min=t.accounts.amount.min(),
                                                  max=t.accounts.amount.max())))
            == set([('Alice', 100, 100), ('Bob', 200, 200)]))
Esempio n. 8
0
def test_column(sql):
    t = bz_data(sql)

    r = list(t['x'])
    assert r == [1, 10, 100]
    assert list(t[['x']]) == [(1, ), (10, ), (100, )]

    assert int(t.count()) == 3
Esempio n. 9
0
def test_client_add_dataset_with_args():
    client.requests = test_add  # OMG more monkey patching
    ec = Client('localhost:6363')
    ec.add('teams',
           'sqlite:///' + example('teams.db'),
           'teams',
           primary_key='teamID')
    assert 'teams' in ec.dshape.measure.dict
    teams_data = bz_data('sqlite:///' + example('teams.db') + '::teams')
    assert ec.dshape.measure.dict['teams'] == teams_data.dshape
Esempio n. 10
0
def test_expr_client_interactive():
    c = Client('localhost:6363')
    t = bz_data(c)

    assert compute(t.accounts.name) == ['Alice', 'Bob']
    assert (into(
        set,
        compute(
            by(t.accounts.name,
               min=t.accounts.amount.min(),
               max=t.accounts.amount.max()))) == set([('Alice', 100, 100),
                                                      ('Bob', 200, 200)]))
Esempio n. 11
0
def test_bz_data_all_in_one():
    ec = bz_data('blaze://localhost:6363')
    assert str(discover(ec)) == str(discover(tdata))
Esempio n. 12
0
def test_bz_data_non_default_port():
    ec = bz_data('blaze://localhost:6364')
    assert ec.data.url == 'http://localhost:6364'
Esempio n. 13
0
def test_bz_data_default_port():
    ec = bz_data('blaze://localhost')
    assert str(discover(ec)) == str(discover(tdata))
Esempio n. 14
0
def test_bz_data():
    c = bz_data('blaze://localhost:6363')
    assert isinstance(c.data, Client)
    assert str(discover(c)) == str(discover(tdata))
Esempio n. 15
0
def test_compute_client_with_multiple_datasets():
    c = bz_data('blaze://localhost:6363')
    s = symbol('s', discover(c))

    assert compute(s.accounts.amount.sum() + s.accounts2.amount.sum(),
                    {s: c}) == 600
Esempio n. 16
0
def test_client_dataset():
    d = bz_data('blaze://localhost')
    assert list(map(tuple, into(list, d.accounts))) == into(list, df)
Esempio n. 17
0
def test_compute_client_with_multiple_datasets():
    c = bz_data('blaze://localhost:6363')
    s = symbol('s', discover(c))

    assert compute(s.accounts.amount.sum() + s.accounts2.amount.sum(),
                   {s: c}) == 600
Esempio n. 18
0
def test_bz_data():
    c = bz_data('blaze://localhost:6363')
    assert isinstance(c.data, Client)
    assert str(discover(c)) == str(discover(tdata))
Esempio n. 19
0
def test_bz_data_all_in_one():
    ec = bz_data('blaze://localhost:6363')
    assert str(discover(ec)) == str(discover(tdata))
Esempio n. 20
0
def test_bz_data_non_default_port():
    ec = bz_data('blaze://localhost:6364')
    assert ec.data.url == 'http://localhost:6364'
Esempio n. 21
0
def test_bz_data_default_port():
    ec = bz_data('blaze://localhost')
    assert str(discover(ec)) == str(discover(tdata))
Esempio n. 22
0
def test_client_dataset_fails():
    with pytest.raises(ValueError):
        bz_data('blaze://localhost::accounts')
    with pytest.raises(ValueError):
        bz_data('blaze://localhost::accounts')
Esempio n. 23
0
def test_client_dataset():
    d = bz_data('blaze://localhost')
    assert list(map(tuple, into(list, d.accounts))) == into(list, df)
Esempio n. 24
0
def sql():
    data = [(1, 2), (10, 20), (100, 200)]
    sql = bz_data("sqlite:///:memory:::foo", dshape="var * {x: int, y: int}")
    into(sql, data)
    return sql
Esempio n. 25
0
def test_client_dataset_fails():
    with pytest.raises(ValueError):
        bz_data('blaze://localhost::accounts')
    with pytest.raises(ValueError):
        bz_data('blaze://localhost::accounts')