Exemplo n.º 1
0
def test_resource_shape():
    with tmpfile('.hdf5') as fn:
        assert resource(fn+'::/data', dshape='10 * int').shape == (10,)
    with tmpfile('.hdf5') as fn:
        assert resource(fn+'::/data', dshape='10 * 10 * int').shape == (10, 10)
    with tmpfile('.hdf5') as fn:
        assert resource(fn+'::/data', dshape='var * 10 * int').shape == (0, 10)
Exemplo n.º 2
0
def test_resource():
    with tmpfile('.hdf5') as fn:
        ds = datashape.dshape('{x: int32, y: 3 * int32}')
        r = resource(fn, dshape=ds)

        assert isinstance(r, h5py.File)
        assert discover(r) == ds

        r2 = resource(fn + '::/x')
        assert isinstance(r2, h5py.Dataset)
Exemplo n.º 3
0
def test_resource_shape():
    with tmpfile('.hdf5') as fn:
        r = resource(fn+'::/data', dshape='10 * int')
        assert r.shape == (10,)
        r.file.close()
    with tmpfile('.hdf5') as fn:
        r = resource(fn+'::/data', dshape='10 * 10 * int')
        assert r.shape == (10, 10)
        r.file.close()
    with tmpfile('.hdf5') as fn:
        r = resource(fn+'::/data', dshape='var * 10 * int')
        assert r.shape == (0, 10)
        r.file.close()
Exemplo n.º 4
0
def test_resource_with_variable_length():
    with tmpfile('.hdf5') as fn:
        os.remove(fn)
        ds = datashape.dshape('var * 4 * int32')
        r = resource(fn + '::/data', dshape=ds)

        assert r.shape == (0, 4)
Exemplo n.º 5
0
def test_resource_with_variable_length():
    with tmpfile('.hdf5') as fn:
        ds = datashape.dshape('var * 4 * int32')
        r = resource(fn + '::/data', dshape=ds)
        try:
            assert r.shape == (0, 4)
        finally:
            r.file.close()
Exemplo n.º 6
0
def test_resource():
    with tmpfile('.hdf5') as fn:
        os.remove(fn)
        ds = datashape.dshape('{x: int32, y: 3 * int32}')
        r = resource(fn, dshape=ds)

        assert isinstance(r, h5py.File)
        assert discover(r) == ds
Exemplo n.º 7
0
def test_resource_with_datapath():
    with tmpfile('.hdf5') as fn:
        ds = datashape.dshape('3 * 4 * int32')
        r = resource(fn + '::/data', dshape=ds)

        assert isinstance(r, h5py.Dataset)
        assert discover(r) == ds
        assert r.file.filename == fn
        assert r.file['/data'] == r