|
21 | 21 | from zarr.core import Array
|
22 | 22 | from zarr.creation import open_array
|
23 | 23 | 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) |
29 | 24 | 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 |
31 | 32 |
|
32 | 33 |
|
33 | 34 | # noinspection PyStatementEffect
|
@@ -971,6 +972,51 @@ def create_store():
|
971 | 972 | return store, None
|
972 | 973 |
|
973 | 974 |
|
| 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 | + |
974 | 1020 | class TestGroupWithZipStore(TestGroup):
|
975 | 1021 |
|
976 | 1022 | @staticmethod
|
|
0 commit comments