Skip to content

Commit 2c12d6b

Browse files
committed
Remove zarr_version
1 parent 81df371 commit 2c12d6b

File tree

6 files changed

+11
-81
lines changed

6 files changed

+11
-81
lines changed

changes/3325.removal.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ The following deprecated functions have been removed:
2828

2929
Setting ``zarr.storage.default_compressor`` is deprecated, use `zarr.config` to configure ``array.v2_default_compressor``
3030
e.g. ``zarr.config.set({'codecs.zstd':'numcodecs.Zstd', 'array.v2_default_compressor.numeric': 'zstd'})``
31+
32+
The ``zarr_version`` argument has been removed throughout the library.
33+
Use the equivalent ``zarr_format`` argument instead.

docs/user-guide/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ For more information, see the
2727

2828
Configuration options include the following:
2929

30-
- Default Zarr format `default_zarr_version`
30+
- Default Zarr format `default_zarr_format`
3131
- Default array order in memory `array.order`
3232
- Whether empty chunks are written to storage `array.write_empty_chunks`
3333
- Async and threading options, e.g. `async.concurrency` and `threading.max_workers`

docs/user-guide/v3_migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ The following sections provide details on breaking changes in Zarr-Python 3.
9797

9898
2. Defaulting to `zarr_format=3` - newly created arrays will use the version 3 of the
9999
Zarr specification. To continue using version 2, set `zarr_format=2` when creating arrays
100-
or set `default_zarr_version=2` in Zarr's runtime configuration.
100+
or set `default_zarr_format=2` in Zarr's runtime configuration.
101101

102102
3. Function signature change to [`zarr.Array.resize`][] - the `resize` function now takes a
103103
`zarr.core.common.ShapeLike` input rather than separate arguments for each dimension.

src/zarr/api/asynchronous.py

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
ArrayNotFoundError,
4242
GroupNotFoundError,
4343
NodeTypeValidationError,
44-
ZarrDeprecationWarning,
4544
ZarrRuntimeWarning,
4645
ZarrUserWarning,
4746
)
@@ -167,22 +166,6 @@ def _like_args(a: ArrayLike) -> _LikeArgs:
167166
return new
168167

169168

170-
def _handle_zarr_version_or_format(
171-
*, zarr_version: ZarrFormat | None, zarr_format: ZarrFormat | None
172-
) -> ZarrFormat | None:
173-
"""Handle the deprecated zarr_version kwarg and return zarr_format"""
174-
if zarr_format is not None and zarr_version is not None and zarr_format != zarr_version:
175-
raise ValueError(
176-
f"zarr_format {zarr_format} does not match zarr_version {zarr_version}, please only set one"
177-
)
178-
if zarr_version is not None:
179-
warnings.warn(
180-
"zarr_version is deprecated, use zarr_format", ZarrDeprecationWarning, stacklevel=2
181-
)
182-
return zarr_version
183-
return zarr_format
184-
185-
186169
async def consolidate_metadata(
187170
store: StoreLike,
188171
path: str | None = None,
@@ -287,7 +270,6 @@ async def load(
287270
store: StoreLike,
288271
path: str | None = None,
289272
zarr_format: ZarrFormat | None = None,
290-
zarr_version: ZarrFormat | None = None,
291273
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]:
292274
"""Load data from an array or group into memory.
293275
@@ -316,8 +298,6 @@ async def load(
316298
If loading data from a group of arrays, data will not be immediately loaded into
317299
memory. Rather, arrays will be loaded into memory as they are requested.
318300
"""
319-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
320-
321301
obj = await open(store=store, path=path, zarr_format=zarr_format)
322302
if isinstance(obj, AsyncArray):
323303
return await obj.getitem(slice(None))
@@ -329,7 +309,6 @@ async def open(
329309
*,
330310
store: StoreLike | None = None,
331311
mode: AccessModeLiteral | None = None,
332-
zarr_version: ZarrFormat | None = None, # deprecated
333312
zarr_format: ZarrFormat | None = None,
334313
path: str | None = None,
335314
storage_options: dict[str, Any] | None = None,
@@ -365,7 +344,6 @@ async def open(
365344
z : array or group
366345
Return type depends on what exists in the given store.
367346
"""
368-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
369347
if mode is None:
370348
if isinstance(store, (Store, StorePath)) and store.read_only:
371349
mode = "r"
@@ -416,7 +394,6 @@ async def open_consolidated(
416394
async def save(
417395
store: StoreLike,
418396
*args: NDArrayLike,
419-
zarr_version: ZarrFormat | None = None, # deprecated
420397
zarr_format: ZarrFormat | None = None,
421398
path: str | None = None,
422399
**kwargs: Any, # TODO: type kwargs as valid args to save
@@ -438,7 +415,6 @@ async def save(
438415
**kwargs
439416
NumPy arrays with data to save.
440417
"""
441-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
442418

443419
if len(args) == 0 and len(kwargs) == 0:
444420
raise ValueError("at least one array must be provided")
@@ -452,7 +428,6 @@ async def save_array(
452428
store: StoreLike,
453429
arr: NDArrayLike,
454430
*,
455-
zarr_version: ZarrFormat | None = None, # deprecated
456431
zarr_format: ZarrFormat | None = None,
457432
path: str | None = None,
458433
storage_options: dict[str, Any] | None = None,
@@ -480,10 +455,7 @@ async def save_array(
480455
**kwargs
481456
Passed through to [`create`][zarr.api.asynchronous.create], e.g., compressor.
482457
"""
483-
zarr_format = (
484-
_handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
485-
or _default_zarr_format()
486-
)
458+
zarr_format = zarr_format or _default_zarr_format()
487459
if not isinstance(arr, NDArrayLike):
488460
raise TypeError("arr argument must be numpy or other NDArrayLike array")
489461

@@ -510,7 +482,6 @@ async def save_array(
510482
async def save_group(
511483
store: StoreLike,
512484
*args: NDArrayLike,
513-
zarr_version: ZarrFormat | None = None, # deprecated
514485
zarr_format: ZarrFormat | None = None,
515486
path: str | None = None,
516487
storage_options: dict[str, Any] | None = None,
@@ -540,13 +511,7 @@ async def save_group(
540511

541512
store_path = await make_store_path(store, path=path, mode="w", storage_options=storage_options)
542513

543-
zarr_format = (
544-
_handle_zarr_version_or_format(
545-
zarr_version=zarr_version,
546-
zarr_format=zarr_format,
547-
)
548-
or _default_zarr_format()
549-
)
514+
zarr_format = zarr_format or _default_zarr_format()
550515

551516
for arg in args:
552517
if not isinstance(arg, NDArrayLike):
@@ -635,7 +600,6 @@ async def group(
635600
cache_attrs: bool | None = None, # not used, default changed
636601
synchronizer: Any | None = None, # not used
637602
path: str | None = None,
638-
zarr_version: ZarrFormat | None = None, # deprecated
639603
zarr_format: ZarrFormat | None = None,
640604
meta_array: Any | None = None, # not used
641605
attributes: dict[str, JSON] | None = None,
@@ -688,7 +652,6 @@ async def group(
688652
cache_attrs=cache_attrs,
689653
synchronizer=synchronizer,
690654
path=path,
691-
zarr_version=zarr_version,
692655
zarr_format=zarr_format,
693656
meta_array=meta_array,
694657
attributes=attributes,
@@ -757,7 +720,6 @@ async def open_group(
757720
path: str | None = None,
758721
chunk_store: StoreLike | None = None, # not used
759722
storage_options: dict[str, Any] | None = None,
760-
zarr_version: ZarrFormat | None = None, # deprecated
761723
zarr_format: ZarrFormat | None = None,
762724
meta_array: Any | None = None, # not used
763725
attributes: dict[str, JSON] | None = None,
@@ -819,8 +781,6 @@ async def open_group(
819781
The new group.
820782
"""
821783

822-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
823-
824784
if cache_attrs is not None:
825785
warnings.warn("cache_attrs is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
826786
if synchronizer is not None:
@@ -874,7 +834,6 @@ async def create(
874834
object_codec: Codec | None = None, # TODO: type has changed
875835
dimension_separator: Literal[".", "/"] | None = None,
876836
write_empty_chunks: bool | None = None,
877-
zarr_version: ZarrFormat | None = None, # deprecated
878837
zarr_format: ZarrFormat | None = None,
879838
meta_array: Any | None = None, # TODO: need type
880839
attributes: dict[str, JSON] | None = None,
@@ -1016,10 +975,7 @@ async def create(
1016975
z : array
1017976
The array.
1018977
"""
1019-
zarr_format = (
1020-
_handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
1021-
or _default_zarr_format()
1022-
)
978+
zarr_format = zarr_format or _default_zarr_format()
1023979

1024980
if synchronizer is not None:
1025981
warnings.warn("synchronizer is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
@@ -1211,7 +1167,6 @@ async def ones_like(a: ArrayLike, **kwargs: Any) -> AnyAsyncArray:
12111167
async def open_array(
12121168
*, # note: this is a change from v2
12131169
store: StoreLike | None = None,
1214-
zarr_version: ZarrFormat | None = None, # deprecated
12151170
zarr_format: ZarrFormat | None = None,
12161171
path: PathLike = "",
12171172
storage_options: dict[str, Any] | None = None,
@@ -1225,8 +1180,6 @@ async def open_array(
12251180
StoreLike object to open. See the
12261181
[storage documentation in the user guide][user-guide-store-like]
12271182
for a description of all valid StoreLike values.
1228-
zarr_version : {2, 3, None}, optional
1229-
The zarr format to use when saving. Deprecated in favor of zarr_format.
12301183
zarr_format : {2, 3, None}, optional
12311184
The zarr format to use when saving.
12321185
path : str, optional
@@ -1246,8 +1199,6 @@ async def open_array(
12461199
mode = kwargs.pop("mode", None)
12471200
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
12481201

1249-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
1250-
12511202
if "write_empty_chunks" in kwargs:
12521203
_warn_write_empty_chunks_kwarg()
12531204

src/zarr/api/synchronous.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ def load(
135135
store: StoreLike,
136136
path: str | None = None,
137137
zarr_format: ZarrFormat | None = None,
138-
zarr_version: ZarrFormat | None = None,
139138
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]:
140139
"""Load data from an array or group into memory.
141140
@@ -164,16 +163,13 @@ def load(
164163
If loading data from a group of arrays, data will not be immediately loaded into
165164
memory. Rather, arrays will be loaded into memory as they are requested.
166165
"""
167-
return sync(
168-
async_api.load(store=store, zarr_version=zarr_version, zarr_format=zarr_format, path=path)
169-
)
166+
return sync(async_api.load(store=store, zarr_format=zarr_format, path=path))
170167

171168

172169
def open(
173170
store: StoreLike | None = None,
174171
*,
175172
mode: AccessModeLiteral | None = None,
176-
zarr_version: ZarrFormat | None = None, # deprecated
177173
zarr_format: ZarrFormat | None = None,
178174
path: str | None = None,
179175
storage_options: dict[str, Any] | None = None,
@@ -213,7 +209,6 @@ def open(
213209
async_api.open(
214210
store=store,
215211
mode=mode,
216-
zarr_version=zarr_version,
217212
zarr_format=zarr_format,
218213
path=path,
219214
storage_options=storage_options,
@@ -238,7 +233,6 @@ def open_consolidated(*args: Any, use_consolidated: Literal[True] = True, **kwar
238233
def save(
239234
store: StoreLike,
240235
*args: NDArrayLike,
241-
zarr_version: ZarrFormat | None = None, # deprecated
242236
zarr_format: ZarrFormat | None = None,
243237
path: str | None = None,
244238
**kwargs: Any, # TODO: type kwargs as valid args to async_api.save
@@ -260,18 +254,13 @@ def save(
260254
**kwargs
261255
NumPy arrays with data to save.
262256
"""
263-
return sync(
264-
async_api.save(
265-
store, *args, zarr_version=zarr_version, zarr_format=zarr_format, path=path, **kwargs
266-
)
267-
)
257+
return sync(async_api.save(store, *args, zarr_format=zarr_format, path=path, **kwargs))
268258

269259

270260
def save_array(
271261
store: StoreLike,
272262
arr: NDArrayLike,
273263
*,
274-
zarr_version: ZarrFormat | None = None, # deprecated
275264
zarr_format: ZarrFormat | None = None,
276265
path: str | None = None,
277266
storage_options: dict[str, Any] | None = None,
@@ -304,7 +293,6 @@ def save_array(
304293
async_api.save_array(
305294
store=store,
306295
arr=arr,
307-
zarr_version=zarr_version,
308296
zarr_format=zarr_format,
309297
path=path,
310298
storage_options=storage_options,
@@ -316,7 +304,6 @@ def save_array(
316304
def save_group(
317305
store: StoreLike,
318306
*args: NDArrayLike,
319-
zarr_version: ZarrFormat | None = None, # deprecated
320307
zarr_format: ZarrFormat | None = None,
321308
path: str | None = None,
322309
storage_options: dict[str, Any] | None = None,
@@ -349,7 +336,6 @@ def save_group(
349336
async_api.save_group(
350337
store,
351338
*args,
352-
zarr_version=zarr_version,
353339
zarr_format=zarr_format,
354340
path=path,
355341
storage_options=storage_options,
@@ -386,7 +372,6 @@ def group(
386372
cache_attrs: bool | None = None, # not used, default changed
387373
synchronizer: Any | None = None, # not used
388374
path: str | None = None,
389-
zarr_version: ZarrFormat | None = None, # deprecated
390375
zarr_format: ZarrFormat | None = None,
391376
meta_array: Any | None = None, # not used
392377
attributes: dict[str, JSON] | None = None,
@@ -436,7 +421,6 @@ def group(
436421
cache_attrs=cache_attrs,
437422
synchronizer=synchronizer,
438423
path=path,
439-
zarr_version=zarr_version,
440424
zarr_format=zarr_format,
441425
meta_array=meta_array,
442426
attributes=attributes,
@@ -455,7 +439,6 @@ def open_group(
455439
path: str | None = None,
456440
chunk_store: StoreLike | None = None, # not used in async api
457441
storage_options: dict[str, Any] | None = None, # not used in async api
458-
zarr_version: ZarrFormat | None = None, # deprecated
459442
zarr_format: ZarrFormat | None = None,
460443
meta_array: Any | None = None, # not used in async api
461444
attributes: dict[str, JSON] | None = None,
@@ -526,7 +509,6 @@ def open_group(
526509
path=path,
527510
chunk_store=chunk_store,
528511
storage_options=storage_options,
529-
zarr_version=zarr_version,
530512
zarr_format=zarr_format,
531513
meta_array=meta_array,
532514
attributes=attributes,
@@ -607,7 +589,6 @@ def create(
607589
object_codec: Codec | None = None, # TODO: type has changed
608590
dimension_separator: Literal[".", "/"] | None = None,
609591
write_empty_chunks: bool | None = None, # TODO: default has changed
610-
zarr_version: ZarrFormat | None = None, # deprecated
611592
zarr_format: ZarrFormat | None = None,
612593
meta_array: Any | None = None, # TODO: need type
613594
attributes: dict[str, JSON] | None = None,
@@ -770,7 +751,6 @@ def create(
770751
object_codec=object_codec,
771752
dimension_separator=dimension_separator,
772753
write_empty_chunks=write_empty_chunks,
773-
zarr_version=zarr_version,
774754
zarr_format=zarr_format,
775755
meta_array=meta_array,
776756
attributes=attributes,
@@ -1327,7 +1307,6 @@ def ones_like(a: ArrayLike, **kwargs: Any) -> AnyArray:
13271307
def open_array(
13281308
store: StoreLike | None = None,
13291309
*,
1330-
zarr_version: ZarrFormat | None = None,
13311310
zarr_format: ZarrFormat | None = None,
13321311
path: PathLike = "",
13331312
storage_options: dict[str, Any] | None = None,
@@ -1341,8 +1320,6 @@ def open_array(
13411320
StoreLike object to open. See the
13421321
[storage documentation in the user guide][user-guide-store-like]
13431322
for a description of all valid StoreLike values.
1344-
zarr_version : {2, 3, None}, optional
1345-
The zarr format to use when saving. Deprecated in favor of zarr_format.
13461323
zarr_format : {2, 3, None}, optional
13471324
The zarr format to use when saving.
13481325
path : str, optional
@@ -1363,7 +1340,6 @@ def open_array(
13631340
sync(
13641341
async_api.open_array(
13651342
store=store,
1366-
zarr_version=zarr_version,
13671343
zarr_format=zarr_format,
13681344
path=path,
13691345
storage_options=storage_options,

src/zarr/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,5 +244,5 @@ def _warn_order_kwarg() -> None:
244244

245245

246246
def _default_zarr_format() -> ZarrFormat:
247-
"""Return the default zarr_version"""
247+
"""Return the default zarr format"""
248248
return cast("ZarrFormat", int(zarr_config.get("default_zarr_format", 3)))

0 commit comments

Comments
 (0)