コード例 #1
0
ファイル: hierarchy.py プロジェクト: vincentschut/zarr
 def _empty_nosync(self, name, **kwargs):
     path = self._item_path(name)
     kwargs.setdefault('synchronizer', self._synchronizer)
     return empty(store=self._store,
                  path=path,
                  chunk_store=self._chunk_store,
                  **kwargs)
コード例 #2
0
def test_empty_like(zarr_version):
    kwargs = _init_creation_kwargs(zarr_version)
    expected_zarr_version = DEFAULT_ZARR_VERSION if zarr_version is None else zarr_version

    # zarr array
    z = empty(100,
              chunks=10,
              dtype='f4',
              compressor=Zlib(5),
              order='F',
              **kwargs)
    # zarr_version will be inferred from z, but have to specify a path in v3
    z2 = empty_like(z, path=kwargs.get('path', None))
    assert z.shape == z2.shape
    assert z.chunks == z2.chunks
    assert z.dtype == z2.dtype
    assert z.compressor.get_config() == z2.compressor.get_config()
    assert z.fill_value == z2.fill_value
    assert z.order == z2.order
    assert (z._store._store_version == z2._store._store_version ==
            expected_zarr_version)

    # numpy array
    a = np.empty(100, dtype='f4')
    z3 = empty_like(a, **kwargs)
    assert a.shape == z3.shape
    assert (100, ) == z3.chunks
    assert a.dtype == z3.dtype
    assert z3.fill_value is None
    assert z3._store._store_version == expected_zarr_version

    # something slightly silly
    a = [0] * 100
    z3 = empty_like(a, shape=200, **kwargs)
    assert (200, ) == z3.shape

    # other array-likes
    b = np.arange(1000).reshape(100, 10)
    c = MockBcolzArray(b, 10)
    z = empty_like(c, **kwargs)
    assert b.shape == z.shape
    assert (10, 10) == z.chunks
    c = MockH5pyDataset(b, chunks=(10, 2))
    z = empty_like(c, **kwargs)
    assert b.shape == z.shape
    assert (10, 2) == z.chunks
    c = MockH5pyDataset(b, chunks=None)
    z = empty_like(c, **kwargs)
    assert b.shape == z.shape
    assert isinstance(z.chunks, tuple)
コード例 #3
0
ファイル: test_creation.py プロジェクト: pombredanne/zarr
def test_empty_like():

    # zarr array
    z = empty(100, chunks=10, dtype='f4', compressor=Zlib(5),
              order='F')
    z2 = empty_like(z)
    eq(z.shape, z2.shape)
    eq(z.chunks, z2.chunks)
    eq(z.dtype, z2.dtype)
    eq(z.compressor.get_config(), z2.compressor.get_config())
    eq(z.fill_value, z2.fill_value)
    eq(z.order, z2.order)

    # numpy array
    a = np.empty(100, dtype='f4')
    z3 = empty_like(a)
    eq(a.shape, z3.shape)
    eq((100,), z3.chunks)
    eq(a.dtype, z3.dtype)
    assert_is_none(z3.fill_value)

    # something slightly silly
    a = [0] * 100
    z3 = empty_like(a, shape=200)
    eq((200,), z3.shape)

    # other array-likes
    b = np.arange(1000).reshape(100, 10)
    c = MockBcolzArray(b, 10)
    z = empty_like(c)
    eq(b.shape, z.shape)
    eq((10, 10), z.chunks)
    c = MockH5pyDataset(b, chunks=(10, 2))
    z = empty_like(c)
    eq(b.shape, z.shape)
    eq((10, 2), z.chunks)
    c = MockH5pyDataset(b, chunks=None)
    z = empty_like(c)
    eq(b.shape, z.shape)
    assert_is_instance(z.chunks, tuple)
コード例 #4
0
ファイル: test_creation.py プロジェクト: martindurant/zarr
def test_empty_like():

    # zarr array
    z = empty(100, chunks=10, dtype='f4', compressor=Zlib(5),
              order='F')
    z2 = empty_like(z)
    assert z.shape == z2.shape
    assert z.chunks == z2.chunks
    assert z.dtype == z2.dtype
    assert z.compressor.get_config() == z2.compressor.get_config()
    assert z.fill_value == z2.fill_value
    assert z.order == z2.order

    # numpy array
    a = np.empty(100, dtype='f4')
    z3 = empty_like(a)
    assert a.shape == z3.shape
    assert (100,) == z3.chunks
    assert a.dtype == z3.dtype
    assert z3.fill_value is None

    # something slightly silly
    a = [0] * 100
    z3 = empty_like(a, shape=200)
    assert (200,) == z3.shape

    # other array-likes
    b = np.arange(1000).reshape(100, 10)
    c = MockBcolzArray(b, 10)
    z = empty_like(c)
    assert b.shape == z.shape
    assert (10, 10) == z.chunks
    c = MockH5pyDataset(b, chunks=(10, 2))
    z = empty_like(c)
    assert b.shape == z.shape
    assert (10, 2) == z.chunks
    c = MockH5pyDataset(b, chunks=None)
    z = empty_like(c)
    assert b.shape == z.shape
    assert isinstance(z.chunks, tuple)
コード例 #5
0
def test_empty_like():

    # zarr array
    z = empty(100, chunks=10, dtype='f4', compressor=Zlib(5),
              order='F')
    z2 = empty_like(z)
    assert z.shape == z2.shape
    assert z.chunks == z2.chunks
    assert z.dtype == z2.dtype
    assert z.compressor.get_config() == z2.compressor.get_config()
    assert z.fill_value == z2.fill_value
    assert z.order == z2.order

    # numpy array
    a = np.empty(100, dtype='f4')
    z3 = empty_like(a)
    assert a.shape == z3.shape
    assert (100,) == z3.chunks
    assert a.dtype == z3.dtype
    assert z3.fill_value is None

    # something slightly silly
    a = [0] * 100
    z3 = empty_like(a, shape=200)
    assert (200,) == z3.shape

    # other array-likes
    b = np.arange(1000).reshape(100, 10)
    c = MockBcolzArray(b, 10)
    z = empty_like(c)
    assert b.shape == z.shape
    assert (10, 10) == z.chunks
    c = MockH5pyDataset(b, chunks=(10, 2))
    z = empty_like(c)
    assert b.shape == z.shape
    assert (10, 2) == z.chunks
    c = MockH5pyDataset(b, chunks=None)
    z = empty_like(c)
    assert b.shape == z.shape
    assert isinstance(z.chunks, tuple)
コード例 #6
0
ファイル: test_creation.py プロジェクト: will133/zarr
def test_empty_like():

    # zarr array
    z = empty(100, chunks=10, dtype='f4', compressor=Zlib(5), order='F')
    z2 = empty_like(z)
    eq(z.shape, z2.shape)
    eq(z.chunks, z2.chunks)
    eq(z.dtype, z2.dtype)
    eq(z.compressor.get_config(), z2.compressor.get_config())
    eq(z.fill_value, z2.fill_value)
    eq(z.order, z2.order)

    # numpy array
    a = np.empty(100, dtype='f4')
    z3 = empty_like(a)
    eq(a.shape, z3.shape)
    eq((100, ), z3.chunks)
    eq(a.dtype, z3.dtype)
    assert_is_none(z3.fill_value)

    # something slightly silly
    a = [0] * 100
    z3 = empty_like(a, shape=200)
    eq((200, ), z3.shape)

    # other array-likes
    b = np.arange(1000).reshape(100, 10)
    c = MockBcolzArray(b, 10)
    z = empty_like(c)
    eq(b.shape, z.shape)
    eq((10, 10), z.chunks)
    c = MockH5pyDataset(b, chunks=(10, 2))
    z = empty_like(c)
    eq(b.shape, z.shape)
    eq((10, 2), z.chunks)
    c = MockH5pyDataset(b, chunks=None)
    z = empty_like(c)
    eq(b.shape, z.shape)
    assert_is_instance(z.chunks, tuple)
コード例 #7
0
def test_empty():
    z = empty(100, chunks=10)
    assert (100, ) == z.shape
    assert (10, ) == z.chunks
コード例 #8
0
ファイル: hierarchy.py プロジェクト: alimanfoo/zarr
 def _empty_nosync(self, name, **kwargs):
     path = self._item_path(name)
     kwargs.setdefault('synchronizer', self._synchronizer)
     return empty(store=self._store, path=path,
                  chunk_store=self._chunk_store, **kwargs)
コード例 #9
0
ファイル: test_creation.py プロジェクト: pombredanne/zarr
def test_empty():
    z = empty(100, chunks=10)
    eq((100,), z.shape)
    eq((10,), z.chunks)
コード例 #10
0
ファイル: test_creation.py プロジェクト: martindurant/zarr
def test_empty():
    z = empty(100, chunks=10)
    assert (100,) == z.shape
    assert (10,) == z.chunks
コード例 #11
0
ファイル: test_creation.py プロジェクト: will133/zarr
def test_empty():
    z = empty(100, chunks=10)
    eq((100, ), z.shape)
    eq((10, ), z.chunks)
コード例 #12
0
def test_empty(zarr_version):
    kwargs = _init_creation_kwargs(zarr_version)
    z = empty(100, chunks=10, **kwargs)
    assert (100, ) == z.shape
    assert (10, ) == z.chunks