Skip to content

Commit 3263209

Browse files
committed
chore: remove group.array
1 parent 9681cf9 commit 3263209

2 files changed

Lines changed: 5 additions & 173 deletions

File tree

src/zarr/core/group.py

Lines changed: 0 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,152 +3009,6 @@ def move(self, source: str, dest: str) -> None:
30093009
"""
30103010
return self._sync(self._async_group.move(source, dest))
30113011

3012-
@deprecated("Use Group.create_array instead.", category=ZarrDeprecationWarning)
3013-
def array(
3014-
self,
3015-
name: str,
3016-
*,
3017-
shape: ShapeLike,
3018-
dtype: npt.DTypeLike,
3019-
chunks: ChunksLike | Literal["auto"] = "auto",
3020-
shards: tuple[int, ...] | Literal["auto"] | None = None,
3021-
filters: FiltersLike = "auto",
3022-
compressors: CompressorsLike = "auto",
3023-
compressor: CompressorLike = None,
3024-
serializer: SerializerLike = "auto",
3025-
fill_value: Any | None = DEFAULT_FILL_VALUE,
3026-
order: MemoryOrder | None = None,
3027-
attributes: dict[str, JSON] | None = None,
3028-
chunk_key_encoding: ChunkKeyEncodingLike | None = None,
3029-
dimension_names: DimensionNamesLike = None,
3030-
storage_options: dict[str, Any] | None = None,
3031-
overwrite: bool = False,
3032-
config: ArrayConfigLike | None = None,
3033-
data: npt.ArrayLike | None = None,
3034-
) -> AnyArray:
3035-
"""Create an array within this group.
3036-
3037-
!!! warning "Deprecated"
3038-
`Group.array()` is deprecated since v3.0.0 and will be removed in a future release.
3039-
Use `Group.create_array` instead.
3040-
3041-
This method lightly wraps [zarr.core.array.create_array][].
3042-
3043-
Parameters
3044-
----------
3045-
name : str
3046-
The name of the array relative to the group. If ``path`` is ``None``, the array will be located
3047-
at the root of the store.
3048-
shape : tuple[int, ...]
3049-
Shape of the array.
3050-
dtype : npt.DTypeLike
3051-
Data type of the array.
3052-
chunks : tuple[int, ...], optional
3053-
Chunk shape of the array.
3054-
If not specified, default are guessed based on the shape and dtype.
3055-
shards : tuple[int, ...], optional
3056-
Shard shape of the array. The default value of ``None`` results in no sharding at all.
3057-
filters : Iterable[Codec] | Literal["auto"], optional
3058-
Iterable of filters to apply to each chunk of the array, in order, before serializing that
3059-
chunk to bytes.
3060-
3061-
For Zarr format 3, a "filter" is a codec that takes an array and returns an array,
3062-
and these values must be instances of [`zarr.abc.codec.ArrayArrayCodec`][], or a
3063-
dict representations of [`zarr.abc.codec.ArrayArrayCodec`][].
3064-
3065-
For Zarr format 2, a "filter" can be any numcodecs codec; you should ensure that the
3066-
the order if your filters is consistent with the behavior of each filter.
3067-
3068-
The default value of ``"auto"`` instructs Zarr to use a default used based on the data
3069-
type of the array and the Zarr format specified. For all data types in Zarr V3, and most
3070-
data types in Zarr V2, the default filters are empty. The only cases where default filters
3071-
are not empty is when the Zarr format is 2, and the data type is a variable-length data type like
3072-
[`zarr.dtype.VariableLengthUTF8`][] or [`zarr.dtype.VariableLengthUTF8`][]. In these cases,
3073-
the default filters contains a single element which is a codec specific to that particular data type.
3074-
3075-
To create an array with no filters, provide an empty iterable or the value ``None``.
3076-
compressors : Iterable[Codec], optional
3077-
List of compressors to apply to the array. Compressors are applied in order, and after any
3078-
filters are applied (if any are specified) and the data is serialized into bytes.
3079-
3080-
For Zarr format 3, a "compressor" is a codec that takes a bytestream, and
3081-
returns another bytestream. Multiple compressors my be provided for Zarr format 3.
3082-
If no ``compressors`` are provided, a default set of compressors will be used.
3083-
These defaults can be changed by modifying the value of ``array.v3_default_compressors``
3084-
in [`zarr.config`][zarr.config].
3085-
Use ``None`` to omit default compressors.
3086-
3087-
For Zarr format 2, a "compressor" can be any numcodecs codec. Only a single compressor may
3088-
be provided for Zarr format 2.
3089-
If no ``compressor`` is provided, a default compressor will be used.
3090-
in [`zarr.config`][zarr.config].
3091-
Use ``None`` to omit the default compressor.
3092-
compressor : Codec, optional
3093-
Deprecated in favor of ``compressors``.
3094-
serializer : dict[str, JSON] | ArrayBytesCodec, optional
3095-
Array-to-bytes codec to use for encoding the array data.
3096-
Zarr format 3 only. Zarr format 2 arrays use implicit array-to-bytes conversion.
3097-
If no ``serializer`` is provided, a default serializer will be used.
3098-
These defaults can be changed by modifying the value of ``array.v3_default_serializer``
3099-
in [`zarr.config`][zarr.config].
3100-
fill_value : Any, optional
3101-
Fill value for the array.
3102-
order : {"C", "F"}, optional
3103-
The memory of the array (default is "C").
3104-
For Zarr format 2, this parameter sets the memory order of the array.
3105-
For Zarr format 3, this parameter is deprecated, because memory order
3106-
is a runtime parameter for Zarr format 3 arrays. The recommended way to specify the memory
3107-
order for Zarr format 3 arrays is via the ``config`` parameter, e.g. ``{'config': 'C'}``.
3108-
If no ``order`` is provided, a default order will be used.
3109-
This default can be changed by modifying the value of ``array.order`` in [`zarr.config`][zarr.config].
3110-
attributes : dict, optional
3111-
Attributes for the array.
3112-
chunk_key_encoding : ChunkKeyEncoding, optional
3113-
A specification of how the chunk keys are represented in storage.
3114-
For Zarr format 3, the default is ``{"name": "default", "separator": "/"}}``.
3115-
For Zarr format 2, the default is ``{"name": "v2", "separator": "."}}``.
3116-
dimension_names : Iterable[str], optional
3117-
The names of the dimensions (default is None).
3118-
Zarr format 3 only. Zarr format 2 arrays should not use this parameter.
3119-
storage_options : dict, optional
3120-
If using an fsspec URL to create the store, these will be passed to the backend implementation.
3121-
Ignored otherwise.
3122-
overwrite : bool, default False
3123-
Whether to overwrite an array with the same name in the store, if one exists.
3124-
config : ArrayConfig or ArrayConfigLike, optional
3125-
Runtime configuration for the array.
3126-
data : array_like
3127-
The data to fill the array with.
3128-
3129-
Returns
3130-
-------
3131-
AsyncArray
3132-
"""
3133-
compressors = _parse_deprecated_compressor(compressor, compressors)
3134-
return Array(
3135-
self._sync(
3136-
self._async_group.create_dataset(
3137-
name=name,
3138-
shape=shape,
3139-
dtype=dtype,
3140-
chunks=chunks,
3141-
shards=shards,
3142-
fill_value=fill_value,
3143-
attributes=attributes,
3144-
chunk_key_encoding=chunk_key_encoding,
3145-
compressors=compressors,
3146-
serializer=serializer,
3147-
dimension_names=dimension_names,
3148-
order=order,
3149-
filters=filters,
3150-
overwrite=overwrite,
3151-
storage_options=storage_options,
3152-
config=config,
3153-
data=data,
3154-
)
3155-
)
3156-
)
3157-
31583012

31593013
async def create_hierarchy(
31603014
*,

tests/test_group.py

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -709,13 +709,11 @@ async def test_group_update_attributes_async(store: Store, zarr_format: ZarrForm
709709
assert new_group.attrs == new_attrs
710710

711711

712-
@pytest.mark.parametrize("method", ["create_array", "array"])
713712
@pytest.mark.parametrize("name", ["a", "/a"])
714713
def test_group_create_array(
715714
store: Store,
716715
zarr_format: ZarrFormat,
717716
overwrite: bool,
718-
method: Literal["create_array", "array"],
719717
name: str,
720718
) -> None:
721719
"""
@@ -726,33 +724,13 @@ def test_group_create_array(
726724
dtype = "uint8"
727725
data = np.arange(np.prod(shape)).reshape(shape).astype(dtype)
728726

729-
if method == "create_array":
730-
array = group.create_array(name=name, shape=shape, dtype=dtype)
731-
array[:] = data
732-
elif method == "array":
733-
with pytest.warns(ZarrDeprecationWarning, match=r"Group\.create_array instead\."):
734-
with pytest.warns(
735-
ZarrUserWarning,
736-
match="The `compressor` argument is deprecated. Use `compressors` instead.",
737-
):
738-
array = group.array(name=name, data=data, shape=shape, dtype=dtype)
739-
else:
740-
raise AssertionError
727+
array = group.create_array(name=name, shape=shape, dtype=dtype)
728+
array[:] = data
741729

742730
if not overwrite:
743-
if method == "create_array":
744-
with pytest.raises(ContainsArrayError): # noqa: PT012
745-
a = group.create_array(name=name, shape=shape, dtype=dtype)
746-
a[:] = data
747-
elif method == "array":
748-
with pytest.raises(ContainsArrayError): # noqa: PT012
749-
with pytest.warns(ZarrDeprecationWarning, match=r"Group\.create_array instead\."):
750-
with pytest.warns(
751-
ZarrUserWarning,
752-
match="The `compressor` argument is deprecated. Use `compressors` instead.",
753-
):
754-
a = group.array(name=name, shape=shape, dtype=dtype)
755-
a[:] = data
731+
with pytest.raises(ContainsArrayError): # noqa: PT012
732+
a = group.create_array(name=name, shape=shape, dtype=dtype)
733+
a[:] = data
756734

757735
assert array.path == normalize_path(name)
758736
assert array.name == "/" + array.path

0 commit comments

Comments
 (0)