|
4 | 4 | import warnings |
5 | 5 | from asyncio import gather |
6 | 6 | from collections.abc import Iterable |
7 | | -from dataclasses import dataclass, field |
| 7 | +from dataclasses import dataclass, field, replace |
8 | 8 | from itertools import starmap |
9 | 9 | from logging import getLogger |
10 | 10 | from typing import ( |
@@ -1227,14 +1227,17 @@ async def _get_selection( |
1227 | 1227 | fill_value=self.metadata.fill_value, |
1228 | 1228 | ) |
1229 | 1229 | if product(indexer.shape) > 0: |
| 1230 | + # need to use the order from the metadata for v2 |
| 1231 | + _config = self._config |
| 1232 | + if self.metadata.zarr_format == 2: |
| 1233 | + _config = replace(_config, order=self.metadata.order) |
| 1234 | + |
1230 | 1235 | # reading chunks and decoding them |
1231 | 1236 | await self.codec_pipeline.read( |
1232 | 1237 | [ |
1233 | 1238 | ( |
1234 | 1239 | self.store_path / self.metadata.encode_chunk_key(chunk_coords), |
1235 | | - self.metadata.get_chunk_spec( |
1236 | | - chunk_coords, self._config, prototype=prototype |
1237 | | - ), |
| 1240 | + self.metadata.get_chunk_spec(chunk_coords, _config, prototype=prototype), |
1238 | 1241 | chunk_selection, |
1239 | 1242 | out_selection, |
1240 | 1243 | ) |
@@ -1351,12 +1354,17 @@ async def _set_selection( |
1351 | 1354 | # Buffer and NDBuffer between components. |
1352 | 1355 | value_buffer = prototype.nd_buffer.from_ndarray_like(value) |
1353 | 1356 |
|
| 1357 | + # need to use the order from the metadata for v2 |
| 1358 | + _config = self._config |
| 1359 | + if self.metadata.zarr_format == 2: |
| 1360 | + _config = replace(_config, order=self.metadata.order) |
| 1361 | + |
1354 | 1362 | # merging with existing data and encoding chunks |
1355 | 1363 | await self.codec_pipeline.write( |
1356 | 1364 | [ |
1357 | 1365 | ( |
1358 | 1366 | self.store_path / self.metadata.encode_chunk_key(chunk_coords), |
1359 | | - self.metadata.get_chunk_spec(chunk_coords, self._config, prototype), |
| 1367 | + self.metadata.get_chunk_spec(chunk_coords, _config, prototype), |
1360 | 1368 | chunk_selection, |
1361 | 1369 | out_selection, |
1362 | 1370 | ) |
@@ -4393,15 +4401,22 @@ def _parse_chunk_encoding_v3( |
4393 | 4401 |
|
4394 | 4402 |
|
4395 | 4403 | def _parse_deprecated_compressor( |
4396 | | - compressor: CompressorLike | None, compressors: CompressorsLike |
| 4404 | + compressor: CompressorLike | None, compressors: CompressorsLike, zarr_format: int = 3 |
4397 | 4405 | ) -> CompressorsLike | None: |
4398 | | - if compressor: |
| 4406 | + if compressor != "auto": |
4399 | 4407 | if compressors != "auto": |
4400 | 4408 | raise ValueError("Cannot specify both `compressor` and `compressors`.") |
4401 | | - warn( |
4402 | | - "The `compressor` argument is deprecated. Use `compressors` instead.", |
4403 | | - category=UserWarning, |
4404 | | - stacklevel=2, |
4405 | | - ) |
4406 | | - compressors = (compressor,) |
| 4409 | + if zarr_format == 3: |
| 4410 | + warn( |
| 4411 | + "The `compressor` argument is deprecated. Use `compressors` instead.", |
| 4412 | + category=UserWarning, |
| 4413 | + stacklevel=2, |
| 4414 | + ) |
| 4415 | + if compressor is None: |
| 4416 | + # "no compression" |
| 4417 | + compressors = () |
| 4418 | + else: |
| 4419 | + compressors = (compressor,) |
| 4420 | + elif zarr_format == 2 and compressor == compressors == "auto": |
| 4421 | + compressors = ({"id": "blosc"},) |
4407 | 4422 | return compressors |
0 commit comments