Esempio n. 1
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()
Esempio n. 2
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()
Esempio n. 3
0
def test_resource():
    with tmpfile('.hdf5') as fn:
        ds = datashape.dshape('{x: int32, y: 3 * int32}')
        r = resource(fn, dshape=ds)
        r2 = resource(fn + '::/x')

        try:
            assert isinstance(r, h5py.File)
            assert discover(r) == ds
            assert isinstance(r2, h5py.Dataset)
        finally:
            r.close()
            r2.file.close()
Esempio n. 4
0
def test_resource():
    with tmpfile('.hdf5') as fn:
        ds = datashape.dshape('{x: int32, y: 3 * int32}')
        r = resource(fn, dshape=ds)
        r2 = resource(fn + '::/x')

        try:
            assert isinstance(r, h5py.File)
            assert discover(r) == ds
            assert isinstance(r2, h5py.Dataset)
        finally:
            r.close()
            r2.file.close()
Esempio 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()
Esempio n. 6
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()
Esempio n. 7
0
def test_resource_with_option_types():
    with tmpfile('.hdf5') as fn:
        ds = datashape.dshape('4 * {name: ?string, amount: ?int32}')
        r = resource(fn + '::/data', dshape=ds)
        try:
            assert r.shape == (4,)
            assert r.dtype == [('name', 'O'), ('amount', 'f4')]
        finally:
            r.file.close()
Esempio n. 8
0
def test_resource_with_option_types():
    with tmpfile('.hdf5') as fn:
        ds = datashape.dshape('4 * {name: ?string, amount: ?int32}')
        r = resource(fn + '::/data', dshape=ds)
        try:
            assert r.shape == (4, )
            assert r.dtype == [('name', 'O'), ('amount', 'f4')]
        finally:
            r.file.close()
Esempio n. 9
0
def test_resource_with_datapath():
    with tmpfile('.hdf5') as fn:
        ds = datashape.dshape('3 * 4 * int32')
        r = resource(fn + '::/data', dshape=ds)

        try:
            assert isinstance(r, h5py.Dataset)
            assert discover(r) == ds
            assert r.file.filename == fn
            assert r.file['/data'] == r
        finally:
            r.file.close()
Esempio n. 10
0
def test_resource_with_datapath():
    with tmpfile('.hdf5') as fn:
        ds = datashape.dshape('3 * 4 * int32')
        r = resource(fn + '::/data', dshape=ds)

        try:
            assert isinstance(r, h5py.Dataset)
            assert discover(r) == ds
            assert r.file.filename == fn
            assert r.file['/data'] == r
        finally:
            r.file.close()
Esempio n. 11
0
def test_resource_with_h5py_protocol():
    with tmpfile('.hdf5') as fn:
        assert isinstance(resource('h5py://' + fn), h5py.File)
    with tmpfile('.xyz') as fn:
        assert isinstance(resource('h5py://' + fn), h5py.File)
Esempio n. 12
0
def test_resource_with_h5py_protocol():
    with tmpfile('.hdf5') as fn:
        assert isinstance(resource('h5py://' + fn), h5py.File)
    with tmpfile('.xyz') as fn:
        assert isinstance(resource('h5py://' + fn), h5py.File)