Skip to content

Commit 81a359d

Browse files
committed
Remove zarr_version
1 parent 4c63166 commit 81a359d

File tree

6 files changed

+12
-83
lines changed

6 files changed

+12
-83
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
ArrayNotFoundError,
4242
GroupNotFoundError,
4343
NodeTypeValidationError,
44-
ZarrDeprecationWarning,
4544
ZarrRuntimeWarning,
4645
ZarrUserWarning,
4746
)
@@ -155,22 +154,6 @@ def _like_args(a: ArrayLike, kwargs: dict[str, Any]) -> dict[str, Any]:
155154
return new
156155

157156

158-
def _handle_zarr_version_or_format(
159-
*, zarr_version: ZarrFormat | None, zarr_format: ZarrFormat | None
160-
) -> ZarrFormat | None:
161-
"""Handle the deprecated zarr_version kwarg and return zarr_format"""
162-
if zarr_format is not None and zarr_version is not None and zarr_format != zarr_version:
163-
raise ValueError(
164-
f"zarr_format {zarr_format} does not match zarr_version {zarr_version}, please only set one"
165-
)
166-
if zarr_version is not None:
167-
warnings.warn(
168-
"zarr_version is deprecated, use zarr_format", ZarrDeprecationWarning, stacklevel=2
169-
)
170-
return zarr_version
171-
return zarr_format
172-
173-
174157
async def consolidate_metadata(
175158
store: StoreLike,
176159
path: str | None = None,
@@ -264,7 +247,6 @@ async def load(
264247
store: StoreLike,
265248
path: str | None = None,
266249
zarr_format: ZarrFormat | None = None,
267-
zarr_version: ZarrFormat | None = None,
268250
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]:
269251
"""Load data from an array or group into memory.
270252
@@ -291,8 +273,6 @@ async def load(
291273
If loading data from a group of arrays, data will not be immediately loaded into
292274
memory. Rather, arrays will be loaded into memory as they are requested.
293275
"""
294-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
295-
296276
obj = await open(store=store, path=path, zarr_format=zarr_format)
297277
if isinstance(obj, AsyncArray):
298278
return await obj.getitem(slice(None))
@@ -304,7 +284,6 @@ async def open(
304284
*,
305285
store: StoreLike | None = None,
306286
mode: AccessModeLiteral | None = None,
307-
zarr_version: ZarrFormat | None = None, # deprecated
308287
zarr_format: ZarrFormat | None = None,
309288
path: str | None = None,
310289
storage_options: dict[str, Any] | None = None,
@@ -338,7 +317,6 @@ async def open(
338317
z : array or group
339318
Return type depends on what exists in the given store.
340319
"""
341-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
342320
if mode is None:
343321
if isinstance(store, (Store, StorePath)) and store.read_only:
344322
mode = "r"
@@ -389,7 +367,6 @@ async def open_consolidated(
389367
async def save(
390368
store: StoreLike,
391369
*args: NDArrayLike,
392-
zarr_version: ZarrFormat | None = None, # deprecated
393370
zarr_format: ZarrFormat | None = None,
394371
path: str | None = None,
395372
**kwargs: Any, # TODO: type kwargs as valid args to save
@@ -409,7 +386,6 @@ async def save(
409386
**kwargs
410387
NumPy arrays with data to save.
411388
"""
412-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
413389

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

@@ -478,7 +450,6 @@ async def save_array(
478450
async def save_group(
479451
store: StoreLike,
480452
*args: NDArrayLike,
481-
zarr_version: ZarrFormat | None = None, # deprecated
482453
zarr_format: ZarrFormat | None = None,
483454
path: str | None = None,
484455
storage_options: dict[str, Any] | None = None,
@@ -506,13 +477,7 @@ async def save_group(
506477

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

509-
zarr_format = (
510-
_handle_zarr_version_or_format(
511-
zarr_version=zarr_version,
512-
zarr_format=zarr_format,
513-
)
514-
or _default_zarr_format()
515-
)
480+
zarr_format = zarr_format or _default_zarr_format()
516481

517482
for arg in args:
518483
if not isinstance(arg, NDArrayLike):
@@ -603,7 +568,6 @@ async def group(
603568
cache_attrs: bool | None = None, # not used, default changed
604569
synchronizer: Any | None = None, # not used
605570
path: str | None = None,
606-
zarr_version: ZarrFormat | None = None, # deprecated
607571
zarr_format: ZarrFormat | None = None,
608572
meta_array: Any | None = None, # not used
609573
attributes: dict[str, JSON] | None = None,
@@ -644,8 +608,6 @@ async def group(
644608
The new group.
645609
"""
646610

647-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
648-
649611
mode: AccessModeLiteral
650612
if overwrite:
651613
mode = "w"
@@ -736,7 +698,6 @@ async def open_group(
736698
path: str | None = None,
737699
chunk_store: StoreLike | None = None, # not used
738700
storage_options: dict[str, Any] | None = None,
739-
zarr_version: ZarrFormat | None = None, # deprecated
740701
zarr_format: ZarrFormat | None = None,
741702
meta_array: Any | None = None, # not used
742703
attributes: dict[str, JSON] | None = None,
@@ -804,8 +765,6 @@ async def open_group(
804765
The new group.
805766
"""
806767

807-
zarr_format = _handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
808-
809768
if cache_attrs is not None:
810769
warnings.warn("cache_attrs is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
811770
if synchronizer is not None:
@@ -858,7 +817,6 @@ async def create(
858817
object_codec: Codec | None = None, # TODO: type has changed
859818
dimension_separator: Literal[".", "/"] | None = None,
860819
write_empty_chunks: bool | None = None,
861-
zarr_version: ZarrFormat | None = None, # deprecated
862820
zarr_format: ZarrFormat | None = None,
863821
meta_array: Any | None = None, # TODO: need type
864822
attributes: dict[str, JSON] | None = None,
@@ -985,10 +943,7 @@ async def create(
985943
z : array
986944
The array.
987945
"""
988-
zarr_format = (
989-
_handle_zarr_version_or_format(zarr_version=zarr_version, zarr_format=zarr_format)
990-
or _default_zarr_format()
991-
)
946+
zarr_format = zarr_format or _default_zarr_format()
992947

993948
if synchronizer is not None:
994949
warnings.warn("synchronizer is not yet implemented", ZarrRuntimeWarning, stacklevel=2)
@@ -1191,7 +1146,6 @@ async def ones_like(
11911146
async def open_array(
11921147
*, # note: this is a change from v2
11931148
store: StoreLike | None = None,
1194-
zarr_version: ZarrFormat | None = None, # deprecated
11951149
zarr_format: ZarrFormat | None = None,
11961150
path: PathLike = "",
11971151
storage_options: dict[str, Any] | None = None,
@@ -1203,8 +1157,6 @@ async def open_array(
12031157
----------
12041158
store : Store or str
12051159
Store or path to directory in file system or name of zip file.
1206-
zarr_version : {2, 3, None}, optional
1207-
The zarr format to use when saving. Deprecated in favor of zarr_format.
12081160
zarr_format : {2, 3, None}, optional
12091161
The zarr format to use when saving.
12101162
path : str, optional
@@ -1224,8 +1176,6 @@ async def open_array(
12241176
mode = kwargs.pop("mode", None)
12251177
store_path = await make_store_path(store, path=path, mode=mode, storage_options=storage_options)
12261178

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

src/zarr/api/synchronous.py

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

157154

158155
def open(
159156
store: StoreLike | None = None,
160157
*,
161158
mode: AccessModeLiteral | None = None,
162-
zarr_version: ZarrFormat | None = None, # deprecated
163159
zarr_format: ZarrFormat | None = None,
164160
path: str | None = None,
165161
storage_options: dict[str, Any] | None = None,
@@ -197,7 +193,6 @@ def open(
197193
async_api.open(
198194
store=store,
199195
mode=mode,
200-
zarr_version=zarr_version,
201196
zarr_format=zarr_format,
202197
path=path,
203198
storage_options=storage_options,
@@ -222,7 +217,6 @@ def open_consolidated(*args: Any, use_consolidated: Literal[True] = True, **kwar
222217
def save(
223218
store: StoreLike,
224219
*args: NDArrayLike,
225-
zarr_version: ZarrFormat | None = None, # deprecated
226220
zarr_format: ZarrFormat | None = None,
227221
path: str | None = None,
228222
**kwargs: Any, # TODO: type kwargs as valid args to async_api.save
@@ -242,18 +236,13 @@ def save(
242236
**kwargs
243237
NumPy arrays with data to save.
244238
"""
245-
return sync(
246-
async_api.save(
247-
store, *args, zarr_version=zarr_version, zarr_format=zarr_format, path=path, **kwargs
248-
)
249-
)
239+
return sync(async_api.save(store, *args, zarr_format=zarr_format, path=path, **kwargs))
250240

251241

252242
def save_array(
253243
store: StoreLike,
254244
arr: NDArrayLike,
255245
*,
256-
zarr_version: ZarrFormat | None = None, # deprecated
257246
zarr_format: ZarrFormat | None = None,
258247
path: str | None = None,
259248
storage_options: dict[str, Any] | None = None,
@@ -283,7 +272,6 @@ def save_array(
283272
async_api.save_array(
284273
store=store,
285274
arr=arr,
286-
zarr_version=zarr_version,
287275
zarr_format=zarr_format,
288276
path=path,
289277
storage_options=storage_options,
@@ -295,7 +283,6 @@ def save_array(
295283
def save_group(
296284
store: StoreLike,
297285
*args: NDArrayLike,
298-
zarr_version: ZarrFormat | None = None, # deprecated
299286
zarr_format: ZarrFormat | None = None,
300287
path: str | None = None,
301288
storage_options: dict[str, Any] | None = None,
@@ -326,7 +313,6 @@ def save_group(
326313
async_api.save_group(
327314
store,
328315
*args,
329-
zarr_version=zarr_version,
330316
zarr_format=zarr_format,
331317
path=path,
332318
storage_options=storage_options,
@@ -363,7 +349,6 @@ def group(
363349
cache_attrs: bool | None = None, # not used, default changed
364350
synchronizer: Any | None = None, # not used
365351
path: str | None = None,
366-
zarr_version: ZarrFormat | None = None, # deprecated
367352
zarr_format: ZarrFormat | None = None,
368353
meta_array: Any | None = None, # not used
369354
attributes: dict[str, JSON] | None = None,
@@ -412,7 +397,6 @@ def group(
412397
cache_attrs=cache_attrs,
413398
synchronizer=synchronizer,
414399
path=path,
415-
zarr_version=zarr_version,
416400
zarr_format=zarr_format,
417401
meta_array=meta_array,
418402
attributes=attributes,
@@ -431,7 +415,6 @@ def open_group(
431415
path: str | None = None,
432416
chunk_store: StoreLike | None = None, # not used in async api
433417
storage_options: dict[str, Any] | None = None, # not used in async api
434-
zarr_version: ZarrFormat | None = None, # deprecated
435418
zarr_format: ZarrFormat | None = None,
436419
meta_array: Any | None = None, # not used in async api
437420
attributes: dict[str, JSON] | None = None,
@@ -508,7 +491,6 @@ def open_group(
508491
path=path,
509492
chunk_store=chunk_store,
510493
storage_options=storage_options,
511-
zarr_version=zarr_version,
512494
zarr_format=zarr_format,
513495
meta_array=meta_array,
514496
attributes=attributes,
@@ -587,7 +569,6 @@ def create(
587569
object_codec: Codec | None = None, # TODO: type has changed
588570
dimension_separator: Literal[".", "/"] | None = None,
589571
write_empty_chunks: bool | None = None, # TODO: default has changed
590-
zarr_version: ZarrFormat | None = None, # deprecated
591572
zarr_format: ZarrFormat | None = None,
592573
meta_array: Any | None = None, # TODO: need type
593574
attributes: dict[str, JSON] | None = None,
@@ -702,7 +683,6 @@ def create(
702683
object_codec=object_codec,
703684
dimension_separator=dimension_separator,
704685
write_empty_chunks=write_empty_chunks,
705-
zarr_version=zarr_version,
706686
zarr_format=zarr_format,
707687
meta_array=meta_array,
708688
attributes=attributes,
@@ -1233,7 +1213,6 @@ def ones_like(a: ArrayLike, **kwargs: Any) -> Array:
12331213
def open_array(
12341214
store: StoreLike | None = None,
12351215
*,
1236-
zarr_version: ZarrFormat | None = None,
12371216
path: PathLike = "",
12381217
storage_options: dict[str, Any] | None = None,
12391218
**kwargs: Any,
@@ -1244,8 +1223,6 @@ def open_array(
12441223
----------
12451224
store : Store or str
12461225
Store or path to directory in file system or name of zip file.
1247-
zarr_version : {2, 3, None}, optional
1248-
The zarr format to use when saving.
12491226
path : str, optional
12501227
Path in store to array.
12511228
storage_options : dict
@@ -1263,7 +1240,6 @@ def open_array(
12631240
sync(
12641241
async_api.open_array(
12651242
store=store,
1266-
zarr_version=zarr_version,
12671243
path=path,
12681244
storage_options=storage_options,
12691245
**kwargs,

0 commit comments

Comments
 (0)