Ejemplo n.º 1
0
def test_create():
    with tmpfile('.hdf5') as fn:
        ds = datashape.dshape('{x: int32, y: {z: 3 * int32}}')
        f = create(h5py.File, dshape='{x: int32, y: {z: 3 * int32}}', path=fn)
        try:
            assert isinstance(f, h5py.File)
            assert f.filename == fn
            assert discover(f) == ds
        finally:
            f.close()
Ejemplo n.º 2
0
def test_create():
    with tmpfile('.hdf5') as fn:
        ds = datashape.dshape('{x: int32, y: {z: 3 * int32}}')
        f = create(h5py.File, dshape='{x: int32, y: {z: 3 * int32}}', path=fn)
        try:
            assert isinstance(f, h5py.File)
            assert f.filename == fn
            assert discover(f) == ds
        finally:
            f.close()
Ejemplo n.º 3
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()
Ejemplo n.º 4
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()
Ejemplo n.º 5
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()
Ejemplo n.º 6
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()
Ejemplo n.º 7
0
def test_discover_on_data_with_object_in_record_name():
    data = np.array([(u'a', 1), (u'b', 2)],
                    dtype=[('lrg_object', unicode_dtype), ('an_int', 'int64')])
    with tmpfile('.hdf5') as fn:
        f = h5py.File(fn)
        try:
            f.create_dataset('/data', data=data)
        except:
            raise
        else:
            assert (discover(f['data']) == datashape.dshape(
                '2 * {lrg_object: string, an_int: int64}'))
        finally:
            with ignoring(Exception):
                f.close()
Ejemplo n.º 8
0
def test_discover_on_data_with_object_in_record_name():
    data = np.array([(u'a', 1), (u'b', 2)], dtype=[('lrg_object',
                                                    unicode_dtype),
                                                   ('an_int', 'int64')])
    with tmpfile('.hdf5') as fn:
        f = h5py.File(fn)
        try:
            f.create_dataset('/data', data=data)
        except:
            raise
        else:
            assert (discover(f['data']) ==
                    datashape.dshape('2 * {lrg_object: string, an_int: int64}'))
        finally:
            with ignoring(Exception):
                f.close()
Ejemplo n.º 9
0
def test_discover():
    with file(x) as (fn, f, dset):
        assert str(discover(dset)) == str(discover(x))
        assert str(discover(f)) == str(discover({'data': x}))
Ejemplo n.º 10
0
def test_discover():
    with file(x) as (fn, f, dset):
        assert str(discover(dset)) == str(discover(x))
        assert str(discover(f)) == str(discover({'data': x}))