|
20 | 20 | from zarr.n5 import N5Store, n5_keywords
|
21 | 21 | from zarr.storage import (ABSStore, DBMStore, DirectoryStore, LMDBStore,
|
22 | 22 | LRUStoreCache, NestedDirectoryStore, SQLiteStore,
|
23 |
| - atexit_rmglob, atexit_rmtree, init_array, init_group) |
| 23 | + atexit_rmglob, atexit_rmtree, init_array, init_group, |
| 24 | + FSStore) |
24 | 25 | from zarr.util import buffer_size
|
25 | 26 | from zarr.tests.util import skip_test_env_var
|
26 | 27 |
|
@@ -2366,3 +2367,54 @@ def create_array(read_only=False, **kwargs):
|
2366 | 2367 | def test_store_has_bytes_values(self):
|
2367 | 2368 | # skip as the cache has no control over how the store provides values
|
2368 | 2369 | pass
|
| 2370 | + |
| 2371 | + |
| 2372 | +class TestArrayWithFSStore(TestArray): |
| 2373 | + |
| 2374 | + @staticmethod |
| 2375 | + def create_array(read_only=False, **kwargs): |
| 2376 | + path = mkdtemp() |
| 2377 | + atexit.register(shutil.rmtree, path) |
| 2378 | + #store = FSStore(f'file:/{path}') |
| 2379 | + store = FSStore(path) |
| 2380 | + print(store) |
| 2381 | + print(store.path) |
| 2382 | + cache_metadata = kwargs.pop('cache_metadata', True) |
| 2383 | + cache_attrs = kwargs.pop('cache_attrs', True) |
| 2384 | + kwargs.setdefault('compressor', Blosc()) |
| 2385 | + init_array(store, **kwargs) |
| 2386 | + return Array(store, read_only=read_only, cache_metadata=cache_metadata, |
| 2387 | + cache_attrs=cache_attrs) |
| 2388 | + |
| 2389 | + def test_hexdigest(self): |
| 2390 | + # Check basic 1-D array |
| 2391 | + z = self.create_array(shape=(1050,), chunks=100, dtype='<i4') |
| 2392 | + assert 'f710da18d45d38d4aaf2afd7fb822fdd73d02957' == z.hexdigest() |
| 2393 | + if hasattr(z.store, 'close'): |
| 2394 | + z.store.close() |
| 2395 | + |
| 2396 | + # Check basic 1-D array with different type |
| 2397 | + z = self.create_array(shape=(1050,), chunks=100, dtype='<f4') |
| 2398 | + assert '1437428e69754b1e1a38bd7fc9e43669577620db' == z.hexdigest() |
| 2399 | + if hasattr(z.store, 'close'): |
| 2400 | + z.store.close() |
| 2401 | + |
| 2402 | + # Check basic 2-D array |
| 2403 | + z = self.create_array(shape=(20, 35,), chunks=10, dtype='<i4') |
| 2404 | + assert '6c530b6b9d73e108cc5ee7b6be3d552cc994bdbe' == z.hexdigest() |
| 2405 | + if hasattr(z.store, 'close'): |
| 2406 | + z.store.close() |
| 2407 | + |
| 2408 | + # Check basic 1-D array with some data |
| 2409 | + z = self.create_array(shape=(1050,), chunks=100, dtype='<i4') |
| 2410 | + z[200:400] = np.arange(200, 400, dtype='i4') |
| 2411 | + assert '4c0a76fb1222498e09dcd92f7f9221d6cea8b40e' == z.hexdigest() |
| 2412 | + if hasattr(z.store, 'close'): |
| 2413 | + z.store.close() |
| 2414 | + |
| 2415 | + # Check basic 1-D array with attributes |
| 2416 | + z = self.create_array(shape=(1050,), chunks=100, dtype='<i4') |
| 2417 | + z.attrs['foo'] = 'bar' |
| 2418 | + assert '05b0663ffe1785f38d3a459dec17e57a18f254af' == z.hexdigest() |
| 2419 | + if hasattr(z.store, 'close'): |
| 2420 | + z.store.close() |
0 commit comments