Skip to content

Commit 749747c

Browse files
committed
Add tests from zarr-developers#718
1 parent c979226 commit 749747c

File tree

1 file changed

+51
-6
lines changed

1 file changed

+51
-6
lines changed

zarr/tests/test_hierarchy.py

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
from zarr.core import Array
2222
from zarr.creation import open_array
2323
from zarr.hierarchy import Group, group, open_group
24-
from zarr.storage import (ABSStore, DBMStore, DirectoryStore, LMDBStore,
25-
LRUStoreCache, MemoryStore, NestedDirectoryStore,
26-
SQLiteStore, ZipStore, array_meta_key, atexit_rmglob,
27-
atexit_rmtree, group_meta_key, init_array,
28-
init_group)
24+
from zarr.storage import (ABSStore, DBMStore, DirectoryStore, FSStore,
25+
LMDBStore, LRUStoreCache, MemoryStore,
26+
NestedDirectoryStore, SQLiteStore, ZipStore,
27+
array_meta_key, atexit_rmglob, atexit_rmtree,
28+
group_meta_key, init_array, init_group)
2929
from zarr.util import InfoReporter
30-
from zarr.tests.util import skip_test_env_var
30+
from zarr.tests.util import skip_test_env_var, have_fsspec
3131

3232

3333
# noinspection PyStatementEffect
@@ -971,6 +971,51 @@ def create_store():
971971
return store, None
972972

973973

974+
@pytest.mark.skipif(have_fsspec is False, reason="needs fsspec")
975+
class TestGroupWithFSStore(TestGroup):
976+
977+
@staticmethod
978+
def create_store():
979+
path = tempfile.mkdtemp()
980+
atexit.register(atexit_rmtree, path)
981+
store = FSStore(path)
982+
return store, None
983+
984+
def test_round_trip_nd(self):
985+
data = np.arange(1000).reshape(10, 10, 10)
986+
name = 'raw'
987+
988+
store, _ = self.create_store()
989+
f = open_group(store, mode='w')
990+
f.create_dataset(name, data=data, chunks=(5, 5, 5),
991+
compressor=None)
992+
h = open_group(store, mode='r')
993+
np.testing.assert_array_equal(h[name][:], data)
994+
995+
996+
@pytest.mark.skipif(have_fsspec is False, reason="needs fsspec")
997+
class TestGroupWithNestedFSStore(TestGroupWithFSStore):
998+
999+
@staticmethod
1000+
def create_store():
1001+
path = tempfile.mkdtemp()
1002+
atexit.register(atexit_rmtree, path)
1003+
store = FSStore(path, key_separator='/', auto_mkdir=True)
1004+
return store, None
1005+
1006+
def test_inconsistent_dimension_separator(self):
1007+
data = np.arange(1000).reshape(10, 10, 10)
1008+
name = 'raw'
1009+
1010+
store, _ = self.create_store()
1011+
f = open_group(store, mode='w')
1012+
1013+
# cannot specify dimension_separator that conflicts with the store
1014+
with pytest.raises(ValueError):
1015+
f.create_dataset(name, data=data, chunks=(5, 5, 5),
1016+
compressor=None, dimension_separator='.')
1017+
1018+
9741019
class TestGroupWithZipStore(TestGroup):
9751020

9761021
@staticmethod

0 commit comments

Comments
 (0)