Example #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
Example #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
Example #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
Example #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
Example #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
Example #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
Example #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)]))
Example #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
Example #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
Example #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)]))
Example #11
0
def test_bz_data_all_in_one():
    ec = bz_data('blaze://localhost:6363')
    assert str(discover(ec)) == str(discover(tdata))
Example #12
0
def test_bz_data_non_default_port():
    ec = bz_data('blaze://localhost:6364')
    assert ec.data.url == 'http://localhost:6364'
Example #13
0
def test_bz_data_default_port():
    ec = bz_data('blaze://localhost')
    assert str(discover(ec)) == str(discover(tdata))
Example #14
0
def test_bz_data():
    c = bz_data('blaze://localhost:6363')
    assert isinstance(c.data, Client)
    assert str(discover(c)) == str(discover(tdata))
Example #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
Example #16
0
def test_client_dataset():
    d = bz_data('blaze://localhost')
    assert list(map(tuple, into(list, d.accounts))) == into(list, df)
Example #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
Example #18
0
def test_bz_data():
    c = bz_data('blaze://localhost:6363')
    assert isinstance(c.data, Client)
    assert str(discover(c)) == str(discover(tdata))
Example #19
0
def test_bz_data_all_in_one():
    ec = bz_data('blaze://localhost:6363')
    assert str(discover(ec)) == str(discover(tdata))
Example #20
0
def test_bz_data_non_default_port():
    ec = bz_data('blaze://localhost:6364')
    assert ec.data.url == 'http://localhost:6364'
Example #21
0
def test_bz_data_default_port():
    ec = bz_data('blaze://localhost')
    assert str(discover(ec)) == str(discover(tdata))
Example #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')
Example #23
0
def test_client_dataset():
    d = bz_data('blaze://localhost')
    assert list(map(tuple, into(list, d.accounts))) == into(list, df)
Example #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
Example #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')