Skip to content

Commit c68ed82

Browse files
committed
Add tests from #718
1 parent c979226 commit c68ed82

File tree

1 file changed

+52
-6
lines changed

1 file changed

+52
-6
lines changed

zarr/tests/test_hierarchy.py

+52-6
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
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)
2924
from zarr.util import InfoReporter
30-
from zarr.tests.util import skip_test_env_var
25+
from zarr.storage import (ABSStore, DBMStore, DirectoryStore, FSStore,
26+
LMDBStore, LRUStoreCache, MemoryStore,
27+
NestedDirectoryStore, SQLiteStore, ZipStore,
28+
array_meta_key, atexit_rmglob, atexit_rmtree,
29+
group_meta_key, init_array, init_group)
30+
from zarr.util import InfoReporter
31+
from zarr.tests.util import skip_test_env_var, have_fsspec
3132

3233

3334
# noinspection PyStatementEffect
@@ -971,6 +972,51 @@ def create_store():
971972
return store, None
972973

973974

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

9761022
@staticmethod

0 commit comments

Comments
 (0)