|  | 
| 1 | 1 | from __future__ import annotations | 
| 2 | 2 | 
 | 
| 3 |  | -import json | 
| 4 | 3 | from dataclasses import dataclass | 
| 5 | 4 | from typing import TYPE_CHECKING | 
| 6 | 5 | 
 | 
|  | 
| 13 | 12 |     TransposeCodec, | 
| 14 | 13 | ) | 
| 15 | 14 | from zarr.core.buffer import default_buffer_prototype | 
| 16 |  | -from zarr.core.indexing import Selection, morton_order_iter | 
| 17 | 15 | from zarr.storage import StorePath | 
| 18 | 16 | 
 | 
| 19 | 17 | if TYPE_CHECKING: | 
| 20 | 18 |     from zarr.abc.codec import Codec | 
| 21 | 19 |     from zarr.abc.store import Store | 
| 22 | 20 |     from zarr.core.buffer.core import NDArrayLike | 
| 23 | 21 |     from zarr.core.common import MemoryOrder | 
|  | 22 | +    from zarr.core.indexing import Selection | 
| 24 | 23 | 
 | 
| 25 | 24 | 
 | 
| 26 | 25 | @dataclass(frozen=True) | 
| @@ -165,51 +164,6 @@ def test_order_implicit( | 
| 165 | 164 |         assert read_data.flags["C_CONTIGUOUS"] | 
| 166 | 165 | 
 | 
| 167 | 166 | 
 | 
| 168 |  | -def test_open(store: Store) -> None: | 
| 169 |  | -    spath = StorePath(store) | 
| 170 |  | -    a = Array.create( | 
| 171 |  | -        spath, | 
| 172 |  | -        shape=(16, 16), | 
| 173 |  | -        chunk_shape=(16, 16), | 
| 174 |  | -        dtype="int32", | 
| 175 |  | -        fill_value=0, | 
| 176 |  | -    ) | 
| 177 |  | -    b = Array.open(spath) | 
| 178 |  | -    assert a.metadata == b.metadata | 
| 179 |  | - | 
| 180 |  | - | 
| 181 |  | -def test_morton() -> None: | 
| 182 |  | -    assert list(morton_order_iter((2, 2))) == [(0, 0), (1, 0), (0, 1), (1, 1)] | 
| 183 |  | -    assert list(morton_order_iter((2, 2, 2))) == [ | 
| 184 |  | -        (0, 0, 0), | 
| 185 |  | -        (1, 0, 0), | 
| 186 |  | -        (0, 1, 0), | 
| 187 |  | -        (1, 1, 0), | 
| 188 |  | -        (0, 0, 1), | 
| 189 |  | -        (1, 0, 1), | 
| 190 |  | -        (0, 1, 1), | 
| 191 |  | -        (1, 1, 1), | 
| 192 |  | -    ] | 
| 193 |  | -    assert list(morton_order_iter((2, 2, 2, 2))) == [ | 
| 194 |  | -        (0, 0, 0, 0), | 
| 195 |  | -        (1, 0, 0, 0), | 
| 196 |  | -        (0, 1, 0, 0), | 
| 197 |  | -        (1, 1, 0, 0), | 
| 198 |  | -        (0, 0, 1, 0), | 
| 199 |  | -        (1, 0, 1, 0), | 
| 200 |  | -        (0, 1, 1, 0), | 
| 201 |  | -        (1, 1, 1, 0), | 
| 202 |  | -        (0, 0, 0, 1), | 
| 203 |  | -        (1, 0, 0, 1), | 
| 204 |  | -        (0, 1, 0, 1), | 
| 205 |  | -        (1, 1, 0, 1), | 
| 206 |  | -        (0, 0, 1, 1), | 
| 207 |  | -        (1, 0, 1, 1), | 
| 208 |  | -        (0, 1, 1, 1), | 
| 209 |  | -        (1, 1, 1, 1), | 
| 210 |  | -    ] | 
| 211 |  | - | 
| 212 |  | - | 
| 213 | 167 | def test_write_partial_chunks(store: Store) -> None: | 
| 214 | 168 |     data = np.arange(0, 256, dtype="uint16").reshape((16, 16)) | 
| 215 | 169 |     spath = StorePath(store) | 
| @@ -241,41 +195,6 @@ async def test_delete_empty_chunks(store: Store) -> None: | 
| 241 | 195 |     assert await store.get(f"{path}/c0/0", prototype=default_buffer_prototype()) is None | 
| 242 | 196 | 
 | 
| 243 | 197 | 
 | 
| 244 |  | -async def test_dimension_names(store: Store) -> None: | 
| 245 |  | -    data = np.arange(0, 256, dtype="uint16").reshape((16, 16)) | 
| 246 |  | -    path = "dimension_names" | 
| 247 |  | -    spath = StorePath(store, path) | 
| 248 |  | -    await AsyncArray.create( | 
| 249 |  | -        spath, | 
| 250 |  | -        shape=data.shape, | 
| 251 |  | -        chunk_shape=(16, 16), | 
| 252 |  | -        dtype=data.dtype, | 
| 253 |  | -        fill_value=0, | 
| 254 |  | -        dimension_names=("x", "y"), | 
| 255 |  | -    ) | 
| 256 |  | - | 
| 257 |  | -    assert (await AsyncArray.open(spath)).metadata.dimension_names == ( | 
| 258 |  | -        "x", | 
| 259 |  | -        "y", | 
| 260 |  | -    ) | 
| 261 |  | -    path2 = "dimension_names2" | 
| 262 |  | -    spath2 = StorePath(store, path2) | 
| 263 |  | -    await AsyncArray.create( | 
| 264 |  | -        spath2, | 
| 265 |  | -        shape=data.shape, | 
| 266 |  | -        chunk_shape=(16, 16), | 
| 267 |  | -        dtype=data.dtype, | 
| 268 |  | -        fill_value=0, | 
| 269 |  | -    ) | 
| 270 |  | - | 
| 271 |  | -    assert (await AsyncArray.open(spath2)).metadata.dimension_names is None | 
| 272 |  | -    zarr_json_buffer = await store.get( | 
| 273 |  | -        f"{path2}/zarr.json", prototype=default_buffer_prototype() | 
| 274 |  | -    ) | 
| 275 |  | -    assert zarr_json_buffer is not None | 
| 276 |  | -    assert "dimension_names" not in json.loads(zarr_json_buffer.to_bytes()) | 
| 277 |  | - | 
| 278 |  | - | 
| 279 | 198 | def test_invalid_metadata(store: Store) -> None: | 
| 280 | 199 |     # LD: Disabled for `zarrs`. Including endianness for a single-byte data type is not invalid. | 
| 281 | 200 |     # spath2 = StorePath(store, "invalid_endian") | 
|  | 
0 commit comments