コード例 #1
0
def test_open_array(path_type):

    store = tempfile.mkdtemp()
    atexit.register(atexit_rmtree, store)
    store = path_type(store)

    # open array, create if doesn't exist
    z = open(store, mode='a', shape=100)
    assert isinstance(z, Array)
    assert z.shape == (100, )

    # open array, overwrite
    z = open(store, mode='w', shape=200)
    assert isinstance(z, Array)
    assert z.shape == (200, )

    # open array, read-only
    z = open(store, mode='r')
    assert isinstance(z, Array)
    assert z.shape == (200, )
    assert z.read_only

    # path not found
    with pytest.raises(ValueError):
        open('doesnotexist', mode='r')
コード例 #2
0
def test_open_group(path_type, zarr_version):

    store = tempfile.mkdtemp()
    atexit.register(atexit_rmtree, store)
    store = path_type(store)
    kwargs = _init_creation_kwargs(zarr_version)

    # open group, create if doesn't exist
    g = open(store, mode='a', **kwargs)
    g.create_group('foo')
    assert isinstance(g, Group)
    assert 'foo' in g

    # open group, overwrite
    g = open(store, mode='w', **kwargs)
    assert isinstance(g, Group)
    assert 'foo' not in g

    if zarr_version == 3:
        # cannot open a v3 group without path
        with pytest.raises(ValueError):
            open(store, mode='w', zarr_version=3)

    # open group, read-only
    g = open(store, mode='r', **kwargs)
    assert isinstance(g, Group)
    assert g.read_only
コード例 #3
0
def test_open_array(path_type, zarr_version):

    store = tempfile.mkdtemp()
    atexit.register(atexit_rmtree, store)
    store = path_type(store)
    kwargs = _init_creation_kwargs(zarr_version)

    # open array, create if doesn't exist
    z = open(store, mode='a', shape=100, **kwargs)
    assert isinstance(z, Array)
    assert z.shape == (100,)

    # open array, overwrite
    z = open(store, mode='w', shape=200, **kwargs)
    assert isinstance(z, Array)
    assert z.shape == (200,)

    if zarr_version == 3:
        # cannot open a v3 array without path
        with pytest.raises(ValueError):
            open(store, mode='w', shape=200, zarr_version=3)

    # open array, read-only
    z = open(store, mode='r', **kwargs)
    assert isinstance(z, Array)
    assert z.shape == (200,)
    assert z.read_only

    # path not found
    with pytest.raises(ValueError):
        open('doesnotexist', mode='r')
コード例 #4
0
def test_open_group():

    store = tempfile.mkdtemp()
    atexit.register(atexit_rmtree, store)

    # open group, create if doesn't exist
    g = open(store, mode='a')
    g.create_group('foo')
    assert isinstance(g, Group)
    assert 'foo' in g

    # open group, overwrite
    g = open(store, mode='w')
    assert isinstance(g, Group)
    assert 'foo' not in g

    # open group, read-only
    g = open(store, mode='r')
    assert isinstance(g, Group)
    assert g.read_only
コード例 #5
0
ファイル: test_convenience.py プロジェクト: pombredanne/zarr
def test_open_group():

    store = tempfile.mkdtemp()
    atexit.register(atexit_rmtree, store)

    # open group, create if doesn't exist
    g = open(store, mode='a')
    g.create_group('foo')
    assert isinstance(g, Group)
    assert 'foo' in g

    # open group, overwrite
    g = open(store, mode='w')
    assert isinstance(g, Group)
    assert 'foo' not in g

    # open group, read-only
    g = open(store, mode='r')
    assert isinstance(g, Group)
    assert g.read_only
コード例 #6
0
ファイル: test_convenience.py プロジェクト: pombredanne/zarr
def test_open_array():

    store = tempfile.mkdtemp()
    atexit.register(atexit_rmtree, store)

    # open array, create if doesn't exist
    z = open(store, mode='a', shape=100)
    assert isinstance(z, Array)
    assert z.shape == (100,)

    # open array, overwrite
    z = open(store, mode='w', shape=200)
    assert isinstance(z, Array)
    assert z.shape == (200,)

    # open array, read-only
    z = open(store, mode='r')
    assert isinstance(z, Array)
    assert z.shape == (200,)
    assert z.read_only

    # path not found
    with assert_raises(ValueError):
        open('doesnotexist', mode='r')