diff --git a/docs/release.rst b/docs/release.rst index e7802fecbb..0098d2e50b 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -61,6 +61,9 @@ Bug fixes * NestedDirectoryStore.listdir now returns chunk keys with the correct '/' dimension_separator. By :user:`Brett Graham ` :issue:`1334`. +* N5Store/N5FSStore dtype returns zarr Stores readable dtype. + By :user:`Marwan Zouinkhi ` :issue:`1339`. + .. _release_2.13.6: 2.13.6 diff --git a/zarr/n5.py b/zarr/n5.py index 4c93ce4acb..1eb6ef2b33 100644 --- a/zarr/n5.py +++ b/zarr/n5.py @@ -689,6 +689,7 @@ def array_metadata_to_zarr(array_metadata: Dict[str, Any], array_metadata['order'] = 'C' array_metadata['filters'] = [] array_metadata['dimension_separator'] = '.' + array_metadata['dtype'] = np.dtype(array_metadata['dtype']).str compressor_config = array_metadata['compressor'] compressor_config = compressor_config_to_zarr(compressor_config) diff --git a/zarr/tests/test_core.py b/zarr/tests/test_core.py index b54fe3ddf0..ba89db3b06 100644 --- a/zarr/tests/test_core.py +++ b/zarr/tests/test_core.py @@ -2034,13 +2034,12 @@ def test_compressors(self): assert np.all(a2[:] == 1) def expected(self): - return [ - '4e9cf910000506455f82a70938a272a3fce932e5', - 'f9d4cbf1402901f63dea7acf764d2546e4b6aa38', - '1d8199f5f7b70d61aa0d29cc375212c3df07d50a', - '874880f91aa6736825584509144afe6b06b0c05c', - 'e2258fedc74752196a8c8383db49e27193c995e2', - ] + return ['8811a77d54caaa1901d5cc4452d946ae433c8d90', + 'd880b007d9779db5f2cdbe13274eb1cbac4a425a', + 'd80eb66d5521744f051e816ab368d8ccfc2e3edf', + '568f9f837e4b682a3819cb122988e2eebeb6572b', + '4fdf4475d786d6694110db5619acd30c80dfc372' + ] @pytest.mark.skipif(have_fsspec is False, reason="needs fsspec") diff --git a/zarr/tests/test_n5.py b/zarr/tests/test_n5.py index a1a0a83e36..8f6d97dd51 100644 --- a/zarr/tests/test_n5.py +++ b/zarr/tests/test_n5.py @@ -1,10 +1,15 @@ - import pytest -from zarr.n5 import N5ChunkWrapper +from zarr.n5 import N5ChunkWrapper, N5FSStore +from zarr.creation import create +from zarr.storage import atexit_rmtree from numcodecs import GZip import numpy as np from typing import Tuple +import json +import atexit + +from zarr.tests.util import have_fsspec def test_make_n5_chunk_wrapper(): @@ -35,3 +40,15 @@ def test_partial_chunk_decode(chunk_shape: Tuple[int, ...]): chunk[subslices] = 1 subchunk = np.ascontiguousarray(chunk[subslices]) assert np.array_equal(codec_wrapped.decode(codec_wrapped.encode(subchunk)), chunk) + + +@pytest.mark.skipif(have_fsspec is False, reason="needs fsspec") +def test_dtype_decode(): + path = 'data/array.n5' + atexit_rmtree(path) + atexit.register(atexit_rmtree, path) + n5_store = N5FSStore(path) + create(100, store=n5_store) + dtype_n5 = json.loads(n5_store[".zarray"])["dtype"] + dtype_zarr = json.loads(create(100).store[".zarray"])["dtype"] + assert dtype_n5 == dtype_zarr