Skip to content

Commit 5630cc6

Browse files
committed
Remove zarr_version
1 parent 7b767bf commit 5630cc6

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
### The Group class
103103

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
)
@@ -166,22 +165,6 @@ def _like_args(a: ArrayLike) -> _LikeArgs:
166165
return new
167166

168167

169-
def _handle_zarr_version_or_format(
170-
*, zarr_version: ZarrFormat | None, zarr_format: ZarrFormat | None
171-
) -> ZarrFormat | None:
172-
"""Handle the deprecated zarr_version kwarg and return zarr_format"""
173-
if zarr_format is not None and zarr_version is not None and zarr_format != zarr_version:
174-
raise ValueError(
175-
f"zarr_format {zarr_format} does not match zarr_version {zarr_version}, please only set one"
176-
)
177-
if zarr_version is not None:
178-
warnings.warn(
179-
"zarr_version is deprecated, use zarr_format", ZarrDeprecationWarning, stacklevel=2
180-
)
181-
return zarr_version
182-
return zarr_format
183-
184-
185168
async def consolidate_metadata(
186169
store: StoreLike,
187170
path: str | None = None,
@@ -284,7 +267,6 @@ async def load(
284267
store: StoreLike,
285268
path: str | None = None,
286269
zarr_format: ZarrFormat | None = None,
287-
zarr_version: ZarrFormat | None = None,
288270
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]:
289271
"""Load data from an array or group into memory.
290272
@@ -311,8 +293,6 @@ async def load(
311293
If loading data from a group of arrays, data will not be immediately loaded into
312294
memory. Rather, arrays will be loaded into memory as they are requested.
313295
"""
314-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
315-
316296
obj = await open(store=store, path=path, zarr_format=zarr_format)
317297
if isinstance(obj, AsyncArray):
318298
return await obj.getitem(slice(None))
@@ -324,7 +304,6 @@ async def open(
324304
*,
325305
store: StoreLike | None = None,
326306
mode: AccessModeLiteral | None = None,
327-
zarr_version: ZarrFormat | None = None, # deprecated
328307
zarr_format: ZarrFormat | None = None,
329308
path: str | None = None,
330309
storage_options: dict[str, Any] | None = None,
@@ -358,7 +337,6 @@ async def open(
358337
z : array or group
359338
Return type depends on what exists in the given store.
360339
"""
361-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
362340
if mode is None:
363341
if isinstance(store, (Store, StorePath)) and store.read_only:
364342
mode = "r"
@@ -409,7 +387,6 @@ async def open_consolidated(
409387
async def save(
410388
store: StoreLike,
411389
*args: NDArrayLike,
412-
zarr_version: ZarrFormat | None = None, # deprecated
413390
zarr_format: ZarrFormat | None = None,
414391
path: str | None = None,
415392
**kwargs: Any, # TODO: type kwargs as valid args to save
@@ -429,7 +406,6 @@ async def save(
429406
**kwargs
430407
NumPy arrays with data to save.
431408
"""
432-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
433409

434410
if len(args) == 0 and len(kwargs) == 0:
435411
raise ValueError("at least one array must be provided")
@@ -443,7 +419,6 @@ async def save_array(
443419
store: StoreLike,
444420
arr: NDArrayLike,
445421
*,
446-
zarr_version: ZarrFormat | None = None, # deprecated
447422
zarr_format: ZarrFormat | None = None,
448423
path: str | None = None,
449424
storage_options: dict[str, Any] | None = None,
@@ -469,10 +444,7 @@ async def save_array(
469444
**kwargs
470445
Passed through to [`create`][zarr.api.asynchronous.create], e.g., compressor.
471446
"""
472-
zarr_format = (
473-
_handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
474-
or _default_zarr_format()
475-
)
447+
zarr_format = zarr_format or _default_zarr_format()
476448
if not isinstance(arr, NDArrayLike):
477449
raise TypeError("arr argument must be numpy or other NDArrayLike array")
478450

@@ -499,7 +471,6 @@ async def save_array(
499471
async def save_group(
500472
store: StoreLike,
501473
*args: NDArrayLike,
502-
zarr_version: ZarrFormat | None = None, # deprecated
503474
zarr_format: ZarrFormat | None = None,
504475
path: str | None = None,
505476
storage_options: dict[str, Any] | None = None,
@@ -527,13 +498,7 @@ async def save_group(
527498

528499
store_path = await make_store_path(store, path=path, mode="w", storage_options=storage_options)
529500

530-
zarr_format = (
531-
_handle_zarr_version_or_format(
532-
zarr_version=zarr_version,
533-
zarr_format=zarr_format,
534-
)
535-
or _default_zarr_format()
536-
)
501+
zarr_format = zarr_format or _default_zarr_format()
537502

538503
for arg in args:
539504
if not isinstance(arg, NDArrayLike):
@@ -624,7 +589,6 @@ async def group(
624589
cache_attrs: bool | None = None, # not used, default changed
625590
synchronizer: Any | None = None, # not used
626591
path: str | None = None,
627-
zarr_version: ZarrFormat | None = None, # deprecated
628592
zarr_format: ZarrFormat | None = None,
629593
meta_array: Any | None = None, # not used
630594
attributes: dict[str, JSON] | None = None,
@@ -675,7 +639,6 @@ async def group(
675639
cache_attrs=cache_attrs,
676640
synchronizer=synchronizer,
677641
path=path,
678-
zarr_version=zarr_version,
679642
zarr_format=zarr_format,
680643
meta_array=meta_array,
681644
attributes=attributes,
@@ -742,7 +705,6 @@ async def open_group(
742705
path: str | None = None,
743706
chunk_store: StoreLike | None = None, # not used
744707
storage_options: dict[str, Any] | None = None,
745-
zarr_version: ZarrFormat | None = None, # deprecated
746708
zarr_format: ZarrFormat | None = None,
747709
meta_array: Any | None = None, # not used
748710
attributes: dict[str, JSON] | None = None,
@@ -810,8 +772,6 @@ async def open_group(
810772
The new group.
811773
"""
812774

813-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
814-
815775
if cache_attrs is not None:
816776
warnings.warn("cache_attrs is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
817777
if synchronizer is not None:
@@ -865,7 +825,6 @@ async def create(
865825
object_codec: Codec | None = None, # TODO: type has changed
866826
dimension_separator: Literal[".", "/"] | None = None,
867827
write_empty_chunks: bool | None = None,
868-
zarr_version: ZarrFormat | None = None, # deprecated
869828
zarr_format: ZarrFormat | None = None,
870829
meta_array: Any | None = None, # TODO: need type
871830
attributes: dict[str, JSON] | None = None,
@@ -1005,10 +964,7 @@ async def create(
1005964
z : array
1006965
The array.
1007966
"""
1008-
zarr_format = (
1009-
_handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
1010-
or _default_zarr_format()
1011-
)
967+
zarr_format = zarr_format or _default_zarr_format()
1012968

1013969
if synchronizer is not None:
1014970
warnings.warn("synchronizer is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
@@ -1212,7 +1168,6 @@ async def ones_like(
12121168
async def open_array(
12131169
*, # note: this is a change from v2
12141170
store: StoreLike | None = None,
1215-
zarr_version: ZarrFormat | None = None, # deprecated
12161171
zarr_format: ZarrFormat | None = None,
12171172
path: PathLike = "",
12181173
storage_options: dict[str, Any] | None = None,
@@ -1224,8 +1179,6 @@ async def open_array(
12241179
----------
12251180
store : StoreLike
12261181
Store or path to directory in file system or name of zip file.
1227-
zarr_version : {2, 3, None}, optional
1228-
The zarr format to use when saving. Deprecated in favor of zarr_format.
12291182
zarr_format : {2, 3, None}, optional
12301183
The zarr format to use when saving.
12311184
path : str, optional
@@ -1245,8 +1198,6 @@ async def open_array(
12451198
mode = kwargs.pop("mode", None)
12461199
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
12471200

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

src/zarr/api/synchronous.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ def load(
132132
store: StoreLike,
133133
path: str | None = None,
134134
zarr_format: ZarrFormat | None = None,
135-
zarr_version: ZarrFormat | None = None,
136135
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]:
137136
"""Load data from an array or group into memory.
138137
@@ -159,16 +158,13 @@ def load(
159158
If loading data from a group of arrays, data will not be immediately loaded into
160159
memory. Rather, arrays will be loaded into memory as they are requested.
161160
"""
162-
return sync(
163-
async_api.load(store=store, zarr_version=zarr_version, zarr_format=zarr_format, path=path)
164-
)
161+
return sync(async_api.load(store=store, zarr_format=zarr_format, path=path))
165162

166163

167164
def open(
168165
store: StoreLike | None = None,
169166
*,
170167
mode: AccessModeLiteral | None = None,
171-
zarr_version: ZarrFormat | None = None, # deprecated
172168
zarr_format: ZarrFormat | None = None,
173169
path: str | None = None,
174170
storage_options: dict[str, Any] | None = None,
@@ -206,7 +202,6 @@ def open(
206202
async_api.open(
207203
store=store,
208204
mode=mode,
209-
zarr_version=zarr_version,
210205
zarr_format=zarr_format,
211206
path=path,
212207
storage_options=storage_options,
@@ -231,7 +226,6 @@ def open_consolidated(*args: Any, use_consolidated: Literal[True] = True, **kwar
231226
def save(
232227
store: StoreLike,
233228
*args: NDArrayLike,
234-
zarr_version: ZarrFormat | None = None, # deprecated
235229
zarr_format: ZarrFormat | None = None,
236230
path: str | None = None,
237231
**kwargs: Any, # TODO: type kwargs as valid args to async_api.save
@@ -251,18 +245,13 @@ def save(
251245
**kwargs
252246
NumPy arrays with data to save.
253247
"""
254-
return sync(
255-
async_api.save(
256-
store, *args, zarr_version=zarr_version, zarr_format=zarr_format, path=path, **kwargs
257-
)
258-
)
248+
return sync(async_api.save(store, *args, zarr_format=zarr_format, path=path, **kwargs))
259249

260250

261251
def save_array(
262252
store: StoreLike,
263253
arr: NDArrayLike,
264254
*,
265-
zarr_version: ZarrFormat | None = None, # deprecated
266255
zarr_format: ZarrFormat | None = None,
267256
path: str | None = None,
268257
storage_options: dict[str, Any] | None = None,
@@ -293,7 +282,6 @@ def save_array(
293282
async_api.save_array(
294283
store=store,
295284
arr=arr,
296-
zarr_version=zarr_version,
297285
zarr_format=zarr_format,
298286
path=path,
299287
storage_options=storage_options,
@@ -305,7 +293,6 @@ def save_array(
305293
def save_group(
306294
store: StoreLike,
307295
*args: NDArrayLike,
308-
zarr_version: ZarrFormat | None = None, # deprecated
309296
zarr_format: ZarrFormat | None = None,
310297
path: str | None = None,
311298
storage_options: dict[str, Any] | None = None,
@@ -336,7 +323,6 @@ def save_group(
336323
async_api.save_group(
337324
store,
338325
*args,
339-
zarr_version=zarr_version,
340326
zarr_format=zarr_format,
341327
path=path,
342328
storage_options=storage_options,
@@ -373,7 +359,6 @@ def group(
373359
cache_attrs: bool | None = None, # not used, default changed
374360
synchronizer: Any | None = None, # not used
375361
path: str | None = None,
376-
zarr_version: ZarrFormat | None = None, # deprecated
377362
zarr_format: ZarrFormat | None = None,
378363
meta_array: Any | None = None, # not used
379364
attributes: dict[str, JSON] | None = None,
@@ -421,7 +406,6 @@ def group(
421406
cache_attrs=cache_attrs,
422407
synchronizer=synchronizer,
423408
path=path,
424-
zarr_version=zarr_version,
425409
zarr_format=zarr_format,
426410
meta_array=meta_array,
427411
attributes=attributes,
@@ -440,7 +424,6 @@ def open_group(
440424
path: str | None = None,
441425
chunk_store: StoreLike | None = None, # not used in async api
442426
storage_options: dict[str, Any] | None = None, # not used in async api
443-
zarr_version: ZarrFormat | None = None, # deprecated
444427
zarr_format: ZarrFormat | None = None,
445428
meta_array: Any | None = None, # not used in async api
446429
attributes: dict[str, JSON] | None = None,
@@ -517,7 +500,6 @@ def open_group(
517500
path=path,
518501
chunk_store=chunk_store,
519502
storage_options=storage_options,
520-
zarr_version=zarr_version,
521503
zarr_format=zarr_format,
522504
meta_array=meta_array,
523505
attributes=attributes,
@@ -596,7 +578,6 @@ def create(
596578
object_codec: Codec | None = None, # TODO: type has changed
597579
dimension_separator: Literal[".", "/"] | None = None,
598580
write_empty_chunks: bool | None = None, # TODO: default has changed
599-
zarr_version: ZarrFormat | None = None, # deprecated
600581
zarr_format: ZarrFormat | None = None,
601582
meta_array: Any | None = None, # TODO: need type
602583
attributes: dict[str, JSON] | None = None,
@@ -757,7 +738,6 @@ def create(
757738
object_codec=object_codec,
758739
dimension_separator=dimension_separator,
759740
write_empty_chunks=write_empty_chunks,
760-
zarr_version=zarr_version,
761741
zarr_format=zarr_format,
762742
meta_array=meta_array,
763743
attributes=attributes,
@@ -1293,7 +1273,6 @@ def ones_like(a: ArrayLike, **kwargs: Any) -> Array:
12931273
def open_array(
12941274
store: StoreLike | None = None,
12951275
*,
1296-
zarr_version: ZarrFormat | None = None,
12971276
zarr_format: ZarrFormat | None = None,
12981277
path: PathLike = "",
12991278
storage_options: dict[str, Any] | None = None,
@@ -1305,8 +1284,6 @@ def open_array(
13051284
----------
13061285
store : StoreLike
13071286
Store or path to directory in file system or name of zip file.
1308-
zarr_version : {2, 3, None}, optional
1309-
The zarr format to use when saving. Deprecated in favor of zarr_format.
13101287
zarr_format : {2, 3, None}, optional
13111288
The zarr format to use when saving.
13121289
path : str, optional
@@ -1327,7 +1304,6 @@ def open_array(
13271304
sync(
13281305
async_api.open_array(
13291306
store=store,
1330-
zarr_version=zarr_version,
13311307
zarr_format=zarr_format,
13321308
path=path,
13331309
storage_options=storage_options,

src/zarr/core/common.py

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

222222

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

0 commit comments

Comments
 (0)