예제 #1
0
파일: test_sql.py 프로젝트: yihongfa/blaze
 def test_create_index_fails(self, sql):
     with pytest.raises(KeyError):
         create_index(sql, 'z', name='zidx')
     with pytest.raises(ValueError):
         create_index(sql, 'x')
     with pytest.raises(ValueError):
         create_index(sql, 'z')
예제 #2
0
파일: test_sql.py 프로젝트: kwmsmith/blaze
def test_create_index_fails(sql):
    with pytest.raises(KeyError):
        create_index(sql, "z", name="zidx")
    with pytest.raises(ValueError):
        create_index(sql, "x")
    with pytest.raises(ValueError):
        create_index(sql, "z")
예제 #3
0
def test_create_index(pyt):
    create_index(pyt, 'id')
    assert 'id' in pyt.colindexes
예제 #4
0
def test_create_multiple_indexes_fails(pyt):
    with pytest.raises(ValueError):
        create_index(pyt, ['id', 'blarg'])

    with pytest.raises(ValueError):
        create_index(pyt, ['foo', 'bar'])
예제 #5
0
def test_create_index(pyt):
    create_index(pyt, 'id')
    assert 'id' in pyt.colindexes
예제 #6
0
파일: test_mongo.py 프로젝트: pgnepal/blaze
 def test_fails_when_using_not_list_of_tuples_or_strings(self, mongo_idx):
     from pymongo import DESCENDING
     with pytest.raises(TypeError):
         create_index(mongo_idx.tmp_collection, [['id', DESCENDING]])
예제 #7
0
파일: test_mongo.py 프로젝트: pgnepal/blaze
 def test_create_composite_index(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, ['id', 'amount'], name='c_idx')
     assert 'c_idx' in mongo_idx.tmp_collection.index_information()
예제 #8
0
파일: test_sql.py 프로젝트: yihongfa/blaze
 def test_create_index_unique(self, sql):
     create_index(sql, 'y', name='y_idx', unique=True)
     assert len(sql.indexes) == 1
     idx = first(sql.indexes)
     assert idx.unique
     assert idx.columns.y == sql.c.y
예제 #9
0
파일: test_mongo.py 프로젝트: vitan/blaze
 def test_create_index(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, 'id', name='idx_id')
     assert 'idx_id' in mongo_idx.tmp_collection.index_information()
예제 #10
0
파일: test_mongo.py 프로젝트: vitan/blaze
 def test_create_composite_index(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, ['id', 'amount'])
     assert 'id_1_amount_1' in mongo_idx.tmp_collection.index_information()
예제 #11
0
파일: hmda.py 프로젝트: vinomaster/blazeres
from blaze import CSV, Table
csv = CSV('hmda_lar-2012.csv')  # Open the CSV file
t = Table(csv)                  # Interact with CSV file using interactive Table object

columns = ['action_taken_name', 'agency_abbr', 'applicant_ethnicity_name',
           'applicant_race_name_1', 'applicant_sex_name', 'county_name',
           'loan_purpose_name', 'state_abbr']

t = t[columns]

t2 = t[t.state_abbr == 'NY']

from blaze import into, by
from pandas import DataFrame
# Group on action_taken_name, count each group
print into(DataFrame, t2.action_taken_name.count_values())

from blaze import SQL
sql = SQL('sqlite:///hmda.db', 'data', schema=t.schema) # A SQLite database
into(sql, t)  # Migrate data

sqlTable = Table(sql)

from blaze import create_index
create_index(sql, 'state_abbr', name='state_abbr_index')

t2 = sqlTable[sqlTable.state_abbr == 'NY']

print into(DataFrame, t2.action_taken_name.count_values())
예제 #12
0
파일: test_sql.py 프로젝트: kwmsmith/blaze
def test_composite_index_fails_with_existing_columns(sql):
    with pytest.raises(KeyError):
        create_index(sql, ["x", "z", "bizz"], name="idx_name")
예제 #13
0
파일: test_sql.py 프로젝트: kwmsmith/blaze
def test_composite_index_fails(sql):
    with pytest.raises(KeyError):
        create_index(sql, ["z", "bizz"], name="idx_name")
예제 #14
0
파일: test_sql.py 프로젝트: kwmsmith/blaze
def test_composite_index(sql):
    create_index(sql, ["x", "y"], name="idx_xy")
    with pytest.raises(OperationalError):
        create_index(sql, ["x", "y"], name="idx_xy")
예제 #15
0
파일: test_sql.py 프로젝트: kwmsmith/blaze
def test_create_index_unique(sql):
    create_index(sql, "y", name="y_idx", unique=True)
    assert len(sql.data.indexes) == 1
    idx = first(sql.data.indexes)
    assert idx.unique
    assert idx.columns.y == sql.data.c.y
예제 #16
0
def test_create_multiple_indexes_fails(pyt):
    with pytest.raises(ValueError):
        create_index(pyt, ['id', 'blarg'])

    with pytest.raises(ValueError):
        create_index(pyt, ['foo', 'bar'])
예제 #17
0
파일: test_sql.py 프로젝트: yihongfa/blaze
 def test_create_index(self, sql):
     create_index(sql, 'x', name='idx')
     with pytest.raises(OperationalError):
         create_index(sql, 'x', name='idx')
예제 #18
0
파일: test_mongo.py 프로젝트: vitan/blaze
 def test_create_index_single_element_list(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, ['id'], name='idx_id')
     assert 'idx_id' in mongo_idx.tmp_collection.index_information()
예제 #19
0
파일: test_sql.py 프로젝트: yihongfa/blaze
 def test_composite_index_fails(self, sql):
     with pytest.raises(KeyError):
         create_index(sql, ['z', 'bizz'], name='idx_name')
예제 #20
0
파일: test_mongo.py 프로젝트: vitan/blaze
 def test_create_composite_index(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, ['id', 'amount'], name='c_idx')
     assert 'c_idx' in mongo_idx.tmp_collection.index_information()
예제 #21
0
파일: test_mongo.py 프로젝트: pgnepal/blaze
 def test_create_index_single_element_list(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, ['id'], name='idx_id')
     assert 'idx_id' in mongo_idx.tmp_collection.index_information()
예제 #22
0
파일: test_mongo.py 프로젝트: vitan/blaze
 def test_create_composite_index_params(self, mongo_idx):
     from pymongo import ASCENDING, DESCENDING
     create_index(mongo_idx.tmp_collection, [('id', ASCENDING),
                                             ('amount', DESCENDING)],
                  name='c_idx')
     assert 'c_idx' in mongo_idx.tmp_collection.index_information()
예제 #23
0
파일: test_mongo.py 프로젝트: pgnepal/blaze
 def test_create_composite_index_params(self, mongo_idx):
     from pymongo import ASCENDING, DESCENDING
     create_index(mongo_idx.tmp_collection,
                  [('id', ASCENDING), ('amount', DESCENDING)],
                  name='c_idx')
     assert 'c_idx' in mongo_idx.tmp_collection.index_information()
예제 #24
0
파일: test_mongo.py 프로젝트: vitan/blaze
 def test_fails_when_using_not_list_of_tuples_or_strings(self, mongo_idx):
     from pymongo import DESCENDING
     with pytest.raises(TypeError):
         create_index(mongo_idx.tmp_collection, [['id', DESCENDING]])
예제 #25
0
파일: test_mongo.py 프로젝트: pgnepal/blaze
 def test_create_index_with_unique(self, mongo_idx):
     coll = mongo_idx.tmp_collection
     create_index(coll, 'id', unique=True, name='c_idx')
     assert coll.index_information()['c_idx']['unique']
예제 #26
0
파일: test_mongo.py 프로젝트: vitan/blaze
 def test_create_index_with_unique(self, mongo_idx):
     coll = mongo_idx.tmp_collection
     create_index(coll, 'id', unique=True, name='c_idx')
     assert coll.index_information()['c_idx']['unique']
예제 #27
0
def test_create_multiple_indexes(pyt):
    create_index(pyt, ['id', 'amount'])
    assert len(pyt.colindexes) == 2
    assert 'id' in pyt.colindexes
    assert 'amount' in pyt.colindexes
예제 #28
0
def test_create_index(pyt):
    create_index(pyt, "id")
    assert "id" in pyt.colindexes
예제 #29
0
def test_create_index_fails(pyt):
    with pytest.raises(AttributeError):
        create_index(pyt, 'no column here!')
예제 #30
0
def test_create_multiple_indexes(pyt):
    create_index(pyt, ["id", "amount"])
    assert len(pyt.colindexes) == 2
    assert "id" in pyt.colindexes
    assert "amount" in pyt.colindexes
예제 #31
0
def test_create_multiple_indexes(pyt):
    create_index(pyt, ['id', 'amount'])
    assert len(pyt.colindexes) == 2
    assert 'id' in pyt.colindexes
    assert 'amount' in pyt.colindexes
예제 #32
0
def test_create_multiple_indexes_fails(pyt):
    with pytest.raises(ValueError):
        create_index(pyt, ["id", "blarg"])

    with pytest.raises(ValueError):
        create_index(pyt, ["foo", "bar"])
예제 #33
0
def test_create_index_fails(pyt):
    with pytest.raises(AttributeError):
        create_index(pyt, 'no column here!')
예제 #34
0
파일: test_sql.py 프로젝트: blaze/blaze
def test_create_index(sql, cols):
    create_index(sql, cols, name='idx')
    with pytest.raises(OperationalError):
        create_index(sql, cols, name='idx')
예제 #35
0
def test_create_index(sql, cols):
    create_index(sql, cols, name='idx')
    with pytest.raises(OperationalError):
        create_index(sql, cols, name='idx')
예제 #36
0
파일: test_mongo.py 프로젝트: pgnepal/blaze
 def test_create_composite_index(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, ['id', 'amount'])
     assert 'id_1_amount_1' in mongo_idx.tmp_collection.index_information()
예제 #37
0
파일: test_sql.py 프로젝트: yihongfa/blaze
 def test_composite_index(self, sql):
     create_index(sql, ['x', 'y'], name='idx_xy')
     with pytest.raises(OperationalError):
         create_index(sql, ['x', 'y'], name='idx_xy')
예제 #38
0
파일: test_mongo.py 프로젝트: pgnepal/blaze
 def test_create_index(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, 'id', name='idx_id')
     assert 'idx_id' in mongo_idx.tmp_collection.index_information()
예제 #39
0
파일: test_sql.py 프로젝트: yihongfa/blaze
 def test_composite_index_fails_with_existing_columns(self, sql):
     with pytest.raises(KeyError):
         create_index(sql, ['x', 'z', 'bizz'], name='idx_name')
예제 #40
0
파일: test_mongo.py 프로젝트: chdoig/blaze
 def test_create_composite_index_params(self, mongo_idx):
     create_index(mongo_idx.tmp_collection,
                  [('id', ASCENDING), ('amount', DESCENDING)])
     assert 'id_1_amount_-1' in mongo_idx.tmp_collection.index_information()