예제 #1
0
def test_resource_existing_carray():
    with tmpfile('.bcolz') as fn:
        r = resource(fn, dshape='var * int32')
        append(r, [1, 2, 3])
        r.flush()
        newr = resource(fn)
        assert isinstance(newr, carray)
예제 #2
0
def test_resource_shape():
    with tmpfile('.bcolz') as fn:
        assert resource(fn, dshape='10 * int').shape == (10,)
    with tmpfile('.bcolz') as fn:
        assert resource(fn, dshape='10 * 10 * int').shape == (10, 10)
    with tmpfile('.bcolz') as fn:
        assert resource(fn, dshape='var * 10 * int').shape == (0, 10)
예제 #3
0
파일: test_bcolz.py 프로젝트: jreback/into
def test_resource_existing_carray():
    with tmpfile('.bcolz') as fn:
        os.remove(fn)
        r = resource(fn, dshape=discover(y))
        append(r, y)
        r.flush()

        r2 = resource(fn)
        assert eq(r2[:], y)
예제 #4
0
def test_resource_carray():
    with tmpfile('.bcolz') as fn:
        r = resource(fn, dshape='var * int32')

        assert isinstance(r, carray)
        assert r.dtype == 'i4'
        assert r.shape == (0,)
예제 #5
0
def test_resource_ctable():
    with tmpfile('.bcolz') as fn:
        r = resource(fn,
                     dshape='var * {name: string[5, "ascii"], balance: int32}')

        assert isinstance(r, ctable)
        assert r.dtype == [('name', 'S5'), ('balance', 'i4')]
예제 #6
0
def test_drop():
    with tmpfile('.bcolz') as fn:
        r = resource(fn, dshape='var * {name: string[5, "ascii"], balance: int32}')

        assert os.path.exists(fn)
        drop(fn)
        assert not os.path.exists(fn)
예제 #7
0
def test_resource_existing_ctable():
    with tmpfile('.bcolz') as fn:
        r = into(fn, y)
        r.flush()

        r2 = resource(fn)
        assert eq(r2[:], y)
예제 #8
0
def test_resource_ctable_correctly_infers_length():
    with tmpfile('.bcolz') as fn:
        r = resource(fn, dshape='100 * int32')

        assert isinstance(r, carray)
        assert r.dtype == 'i4'
        assert get_expectedlen(r) == 100
예제 #9
0
def test_resource_ctable_correctly_infers_length():
    with tmpfile('.bcolz') as fn:
        r = resource(fn,
                     dshape='100 * {name: string[5, "ascii"], balance: int32}')

        assert isinstance(r, ctable)
        assert r.dtype == [('name', 'S5'), ('balance', 'i4')]
        assert all(get_expectedlen(r[c]) == 100 for c in r.names)
예제 #10
0
def test_resource_carray_overrides_expectedlen():
    with tmpfile('.bcolz') as fn:
        r = resource(fn, dshape='100 * int32', expectedlen=200)

        assert isinstance(r, carray)
        assert r.dtype == 'i4'
        assert r.shape == (100,)
        assert get_expectedlen(r) == 200
예제 #11
0
def tmpbcolz(*args, **kwargs):
    fn = '.%s.bcolz' % str(uuid.uuid1())
    r = resource(fn, *args, **kwargs)

    try:
        yield r
    finally:
        with ignoring(Exception):
            r.flush()
        if os.path.exists(fn):
            shutil.rmtree(fn)
예제 #12
0
def test_resource_existing_carray():
    with tmpbcolz(dshape='var * int32') as r:
        append(r, [1, 2, 3])
        r.flush()
        newr = resource(r.rootdir)
        assert isinstance(newr, carray)