Skip to content

Commit 35818a4

Browse files
committed
Remove zarr_version
1 parent 9464a0b commit 35818a4

File tree

7 files changed

+12
-89
lines changed

7 files changed

+12
-89
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.rst

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

2727
Configuration options include the following:
2828

29-
- Default Zarr format ``default_zarr_version``
29+
- Default Zarr format ``default_zarr_format``
3030
- Default array order in memory ``array.order``
3131
- Default filters, serializers and compressors, e.g. ``array.v3_default_filters``, ``array.v3_default_serializer``, ``array.v3_default_compressors``, ``array.v2_default_filters`` and ``array.v2_default_compressor``
3232
- Whether empty chunks are written to storage ``array.write_empty_chunks``

docs/user-guide/v3_migration.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ The Array class
105105

106106
2. Defaulting to ``zarr_format=3`` - newly created arrays will use the version 3 of the
107107
Zarr specification. To continue using version 2, set ``zarr_format=2`` when creating arrays
108-
or set ``default_zarr_version=2`` in Zarr's :ref:`runtime configuration <user-guide-config>`.
108+
or set ``default_zarr_format=2`` in Zarr's :ref:`runtime configuration <user-guide-config>`.
109109

110110
The Group class
111111
~~~~~~~~~~~~~~~
@@ -207,7 +207,7 @@ Miscellaneous
207207

208208
- The keyword argument ``zarr_version`` available in most creation functions in :mod:`zarr`
209209
(e.g. :func:`zarr.create`, :func:`zarr.open`, :func:`zarr.group`, :func:`zarr.array`) has
210-
been deprecated in favor of ``zarr_format``.
210+
been removed in favor of ``zarr_format``.
211211

212212
🚧 Work in Progress 🚧
213213
----------------------

src/zarr/api/asynchronous.py

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
from zarr.errors import (
4242
GroupNotFoundError,
4343
NodeTypeValidationError,
44-
ZarrDeprecationWarning,
4544
ZarrRuntimeWarning,
4645
ZarrUserWarning,
4746
)
@@ -156,22 +155,6 @@ def _like_args(a: ArrayLike, kwargs: dict[str, Any]) -> dict[str, Any]:
156155
return new
157156

158157

159-
def _handle_zarr_version_or_format(
160-
*, zarr_version: ZarrFormat | None, zarr_format: ZarrFormat | None
161-
) -> ZarrFormat | None:
162-
"""Handle the deprecated zarr_version kwarg and return zarr_format"""
163-
if zarr_format is not None and zarr_version is not None and zarr_format != zarr_version:
164-
raise ValueError(
165-
f"zarr_format {zarr_format} does not match zarr_version {zarr_version}, please only set one"
166-
)
167-
if zarr_version is not None:
168-
warnings.warn(
169-
"zarr_version is deprecated, use zarr_format", ZarrDeprecationWarning, stacklevel=2
170-
)
171-
return zarr_version
172-
return zarr_format
173-
174-
175158
async def consolidate_metadata(
176159
store: StoreLike,
177160
path: str | None = None,
@@ -265,7 +248,6 @@ async def load(
265248
store: StoreLike,
266249
path: str | None = None,
267250
zarr_format: ZarrFormat | None = None,
268-
zarr_version: ZarrFormat | None = None,
269251
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]:
270252
"""Load data from an array or group into memory.
271253
@@ -292,8 +274,6 @@ async def load(
292274
If loading data from a group of arrays, data will not be immediately loaded into
293275
memory. Rather, arrays will be loaded into memory as they are requested.
294276
"""
295-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
296-
297277
obj = await open(store=store, path=path, zarr_format=zarr_format)
298278
if isinstance(obj, AsyncArray):
299279
return await obj.getitem(slice(None))
@@ -305,7 +285,6 @@ async def open(
305285
*,
306286
store: StoreLike | None = None,
307287
mode: AccessModeLiteral | None = None,
308-
zarr_version: ZarrFormat | None = None, # deprecated
309288
zarr_format: ZarrFormat | None = None,
310289
path: str | None = None,
311290
storage_options: dict[str, Any] | None = None,
@@ -339,7 +318,6 @@ async def open(
339318
z : array or group
340319
Return type depends on what exists in the given store.
341320
"""
342-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
343321
if mode is None:
344322
if isinstance(store, (Store, StorePath)) and store.read_only:
345323
mode = "r"
@@ -388,7 +366,6 @@ async def open_consolidated(
388366
async def save(
389367
store: StoreLike,
390368
*args: NDArrayLike,
391-
zarr_version: ZarrFormat | None = None, # deprecated
392369
zarr_format: ZarrFormat | None = None,
393370
path: str | None = None,
394371
**kwargs: Any, # TODO: type kwargs as valid args to save
@@ -408,7 +385,6 @@ async def save(
408385
**kwargs
409386
NumPy arrays with data to save.
410387
"""
411-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
412388

413389
if len(args) == 0 and len(kwargs) == 0:
414390
raise ValueError("at least one array must be provided")
@@ -422,7 +398,6 @@ async def save_array(
422398
store: StoreLike,
423399
arr: NDArrayLike,
424400
*,
425-
zarr_version: ZarrFormat | None = None, # deprecated
426401
zarr_format: ZarrFormat | None = None,
427402
path: str | None = None,
428403
storage_options: dict[str, Any] | None = None,
@@ -447,10 +422,7 @@ async def save_array(
447422
**kwargs
448423
Passed through to :func:`create`, e.g., compressor.
449424
"""
450-
zarr_format = (
451-
_handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
452-
or _default_zarr_format()
453-
)
425+
zarr_format = zarr_format or _default_zarr_format()
454426
if not isinstance(arr, NDArrayLike):
455427
raise TypeError("arr argument must be numpy or other NDArrayLike array")
456428

@@ -477,7 +449,6 @@ async def save_array(
477449
async def save_group(
478450
store: StoreLike,
479451
*args: NDArrayLike,
480-
zarr_version: ZarrFormat | None = None, # deprecated
481452
zarr_format: ZarrFormat | None = None,
482453
path: str | None = None,
483454
storage_options: dict[str, Any] | None = None,
@@ -505,13 +476,7 @@ async def save_group(
505476

506477
store_path = await make_store_path(store, path=path, mode="w", storage_options=storage_options)
507478

508-
zarr_format = (
509-
_handle_zarr_version_or_format(
510-
zarr_version=zarr_version,
511-
zarr_format=zarr_format,
512-
)
513-
or _default_zarr_format()
514-
)
479+
zarr_format = zarr_format or _default_zarr_format()
515480

516481
for arg in args:
517482
if not isinstance(arg, NDArrayLike):
@@ -602,7 +567,6 @@ async def group(
602567
cache_attrs: bool | None = None, # not used, default changed
603568
synchronizer: Any | None = None, # not used
604569
path: str | None = None,
605-
zarr_version: ZarrFormat | None = None, # deprecated
606570
zarr_format: ZarrFormat | None = None,
607571
meta_array: Any | None = None, # not used
608572
attributes: dict[str, JSON] | None = None,
@@ -643,8 +607,6 @@ async def group(
643607
The new group.
644608
"""
645609

646-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
647-
648610
mode: AccessModeLiteral
649611
if overwrite:
650612
mode = "w"
@@ -735,7 +697,6 @@ async def open_group(
735697
path: str | None = None,
736698
chunk_store: StoreLike | None = None, # not used
737699
storage_options: dict[str, Any] | None = None,
738-
zarr_version: ZarrFormat | None = None, # deprecated
739700
zarr_format: ZarrFormat | None = None,
740701
meta_array: Any | None = None, # not used
741702
attributes: dict[str, JSON] | None = None,
@@ -803,8 +764,6 @@ async def open_group(
803764
The new group.
804765
"""
805766

806-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
807-
808767
if cache_attrs is not None:
809768
warnings.warn("cache_attrs is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
810769
if synchronizer is not None:
@@ -857,7 +816,6 @@ async def create(
857816
object_codec: Codec | None = None, # TODO: type has changed
858817
dimension_separator: Literal[".", "/"] | None = None,
859818
write_empty_chunks: bool | None = None,
860-
zarr_version: ZarrFormat | None = None, # deprecated
861819
zarr_format: ZarrFormat | None = None,
862820
meta_array: Any | None = None, # TODO: need type
863821
attributes: dict[str, JSON] | None = None,
@@ -984,10 +942,7 @@ async def create(
984942
z : array
985943
The array.
986944
"""
987-
zarr_format = (
988-
_handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
989-
or _default_zarr_format()
990-
)
945+
zarr_format = zarr_format or _default_zarr_format()
991946

992947
if synchronizer is not None:
993948
warnings.warn("synchronizer is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
@@ -1190,7 +1145,6 @@ async def ones_like(
11901145
async def open_array(
11911146
*, # note: this is a change from v2
11921147
store: StoreLike | None = None,
1193-
zarr_version: ZarrFormat | None = None, # deprecated
11941148
zarr_format: ZarrFormat | None = None,
11951149
path: PathLike = "",
11961150
storage_options: dict[str, Any] | None = None,
@@ -1202,8 +1156,6 @@ async def open_array(
12021156
----------
12031157
store : Store or str
12041158
Store or path to directory in file system or name of zip file.
1205-
zarr_version : {2, 3, None}, optional
1206-
The zarr format to use when saving. Deprecated in favor of zarr_format.
12071159
zarr_format : {2, 3, None}, optional
12081160
The zarr format to use when saving.
12091161
path : str, optional
@@ -1223,8 +1175,6 @@ async def open_array(
12231175
mode = kwargs.pop("mode", None)
12241176
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
12251177

1226-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
1227-
12281178
if "write_empty_chunks" in kwargs:
12291179
_warn_write_empty_chunks_kwarg()
12301180

src/zarr/api/synchronous.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def load(
124124
store: StoreLike,
125125
path: str | None = None,
126126
zarr_format: ZarrFormat | None = None,
127-
zarr_version: ZarrFormat | None = None,
128127
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]:
129128
"""Load data from an array or group into memory.
130129
@@ -151,16 +150,13 @@ def load(
151150
If loading data from a group of arrays, data will not be immediately loaded into
152151
memory. Rather, arrays will be loaded into memory as they are requested.
153152
"""
154-
return sync(
155-
async_api.load(store=store, zarr_version=zarr_version, zarr_format=zarr_format, path=path)
156-
)
153+
return sync(async_api.load(store=store, zarr_format=zarr_format, path=path))
157154

158155

159156
def open(
160157
store: StoreLike | None = None,
161158
*,
162159
mode: AccessModeLiteral | None = None,
163-
zarr_version: ZarrFormat | None = None, # deprecated
164160
zarr_format: ZarrFormat | None = None,
165161
path: str | None = None,
166162
storage_options: dict[str, Any] | None = None,
@@ -198,7 +194,6 @@ def open(
198194
async_api.open(
199195
store=store,
200196
mode=mode,
201-
zarr_version=zarr_version,
202197
zarr_format=zarr_format,
203198
path=path,
204199
storage_options=storage_options,
@@ -223,7 +218,6 @@ def open_consolidated(*args: Any, use_consolidated: Literal[True] = True, **kwar
223218
def save(
224219
store: StoreLike,
225220
*args: NDArrayLike,
226-
zarr_version: ZarrFormat | None = None, # deprecated
227221
zarr_format: ZarrFormat | None = None,
228222
path: str | None = None,
229223
**kwargs: Any, # TODO: type kwargs as valid args to async_api.save
@@ -243,18 +237,13 @@ def save(
243237
**kwargs
244238
NumPy arrays with data to save.
245239
"""
246-
return sync(
247-
async_api.save(
248-
store, *args, zarr_version=zarr_version, zarr_format=zarr_format, path=path, **kwargs
249-
)
250-
)
240+
return sync(async_api.save(store, *args, zarr_format=zarr_format, path=path, **kwargs))
251241

252242

253243
def save_array(
254244
store: StoreLike,
255245
arr: NDArrayLike,
256246
*,
257-
zarr_version: ZarrFormat | None = None, # deprecated
258247
zarr_format: ZarrFormat | None = None,
259248
path: str | None = None,
260249
storage_options: dict[str, Any] | None = None,
@@ -284,7 +273,6 @@ def save_array(
284273
async_api.save_array(
285274
store=store,
286275
arr=arr,
287-
zarr_version=zarr_version,
288276
zarr_format=zarr_format,
289277
path=path,
290278
storage_options=storage_options,
@@ -296,7 +284,6 @@ def save_array(
296284
def save_group(
297285
store: StoreLike,
298286
*args: NDArrayLike,
299-
zarr_version: ZarrFormat | None = None, # deprecated
300287
zarr_format: ZarrFormat | None = None,
301288
path: str | None = None,
302289
storage_options: dict[str, Any] | None = None,
@@ -327,7 +314,6 @@ def save_group(
327314
async_api.save_group(
328315
store,
329316
*args,
330-
zarr_version=zarr_version,
331317
zarr_format=zarr_format,
332318
path=path,
333319
storage_options=storage_options,
@@ -364,7 +350,6 @@ def group(
364350
cache_attrs: bool | None = None, # not used, default changed
365351
synchronizer: Any | None = None, # not used
366352
path: str | None = None,
367-
zarr_version: ZarrFormat | None = None, # deprecated
368353
zarr_format: ZarrFormat | None = None,
369354
meta_array: Any | None = None, # not used
370355
attributes: dict[str, JSON] | None = None,
@@ -413,7 +398,6 @@ def group(
413398
cache_attrs=cache_attrs,
414399
synchronizer=synchronizer,
415400
path=path,
416-
zarr_version=zarr_version,
417401
zarr_format=zarr_format,
418402
meta_array=meta_array,
419403
attributes=attributes,
@@ -432,7 +416,6 @@ def open_group(
432416
path: str | None = None,
433417
chunk_store: StoreLike | None = None, # not used in async api
434418
storage_options: dict[str, Any] | None = None, # not used in async api
435-
zarr_version: ZarrFormat | None = None, # deprecated
436419
zarr_format: ZarrFormat | None = None,
437420
meta_array: Any | None = None, # not used in async api
438421
attributes: dict[str, JSON] | None = None,
@@ -509,7 +492,6 @@ def open_group(
509492
path=path,
510493
chunk_store=chunk_store,
511494
storage_options=storage_options,
512-
zarr_version=zarr_version,
513495
zarr_format=zarr_format,
514496
meta_array=meta_array,
515497
attributes=attributes,
@@ -588,7 +570,6 @@ def create(
588570
object_codec: Codec | None = None, # TODO: type has changed
589571
dimension_separator: Literal[".", "/"] | None = None,
590572
write_empty_chunks: bool | None = None, # TODO: default has changed
591-
zarr_version: ZarrFormat | None = None, # deprecated
592573
zarr_format: ZarrFormat | None = None,
593574
meta_array: Any | None = None, # TODO: need type
594575
attributes: dict[str, JSON] | None = None,
@@ -703,7 +684,6 @@ def create(
703684
object_codec=object_codec,
704685
dimension_separator=dimension_separator,
705686
write_empty_chunks=write_empty_chunks,
706-
zarr_version=zarr_version,
707687
zarr_format=zarr_format,
708688
meta_array=meta_array,
709689
attributes=attributes,
@@ -1235,7 +1215,6 @@ def ones_like(a: ArrayLike, **kwargs: Any) -> Array:
12351215
def open_array(
12361216
store: StoreLike | None = None,
12371217
*,
1238-
zarr_version: ZarrFormat | None = None,
12391218
path: PathLike = "",
12401219
storage_options: dict[str, Any] | None = None,
12411220
**kwargs: Any,
@@ -1246,8 +1225,6 @@ def open_array(
12461225
----------
12471226
store : Store or str
12481227
Store or path to directory in file system or name of zip file.
1249-
zarr_version : {2, 3, None}, optional
1250-
The zarr format to use when saving.
12511228
path : str, optional
12521229
Path in store to array.
12531230
storage_options : dict
@@ -1265,7 +1242,6 @@ def open_array(
12651242
sync(
12661243
async_api.open_array(
12671244
store=store,
1268-
zarr_version=zarr_version,
12691245
path=path,
12701246
storage_options=storage_options,
12711247
**kwargs,

0 commit comments

Comments
 (0)