@@ -3740,11 +3740,11 @@ async def from_array(
37403740 store : str | StoreLike ,
37413741 * ,
37423742 name : str | None = None ,
3743- chunks : ChunkCoords | Literal ["auto" ] = "auto " ,
3743+ chunks : Literal ["auto" , "keep" ] | ChunkCoords = "keep " ,
37443744 shards : ShardsLike | None = None ,
3745- filters : FiltersLike = "auto " ,
3746- compressors : CompressorsLike = "auto " ,
3747- serializer : SerializerLike = "auto " ,
3745+ filters : FiltersLike | Literal [ "keep" ] = "keep " ,
3746+ compressors : CompressorsLike | Literal [ "keep" ] = "keep " ,
3747+ serializer : SerializerLike | Literal [ "keep" ] = "keep " ,
37483748 fill_value : Any | None = None ,
37493749 order : MemoryOrder | None = None ,
37503750 zarr_format : ZarrFormat | None = 3 ,
@@ -3766,12 +3766,14 @@ async def from_array(
37663766 name : str or None, optional
37673767 The name of the array within the store. If ``name`` is ``None``, the array will be located
37683768 at the root of the store.
3769- chunks : ChunkCoords, optional
3769+ chunks : ChunkCoords or "auto" or "keep" , optional
37703770 Chunk shape of the array.
37713771 If not specified, defaults to the chunk shape of the data array.
3772+ - "auto": Automatically determine the chunk shape based on the array's shape and dtype.
3773+ - "keep": Retain the chunk shape of the input array.
37723774 shards : ChunkCoords, optional
37733775 Shard shape of the array. The default value of ``None`` results in no sharding at all.
3774- filters : Iterable[Codec], optional
3776+ filters : Iterable[Codec] or "auto" or "keep" , optional
37753777 Iterable of filters to apply to each chunk of the array, in order, before serializing that
37763778 chunk to bytes.
37773779
@@ -3783,7 +3785,9 @@ async def from_array(
37833785 the order if your filters is consistent with the behavior of each filter.
37843786
37853787 If no ``filters`` are provided, defaults to the filters of the data array.
3786- compressors : Iterable[Codec], optional
3788+ - "auto": Automatically determine the filters based on the array's dtype.
3789+ - "keep": Retain the filters of the input array.
3790+ compressors : Iterable[Codec] or "auto" or "keep", optional
37873791 List of compressors to apply to the array. Compressors are applied in order, and after any
37883792 filters are applied (if any are specified) and the data is serialized into bytes.
37893793
@@ -3794,11 +3798,15 @@ async def from_array(
37943798 be provided for Zarr format 2.
37953799
37963800 If no ``compressors`` are provided, defaults to the compressors of the data array.
3797- serializer : dict[str, JSON] | ArrayBytesCodec, optional
3801+ - "auto": Automatically determine the compressors based on the array's dtype.
3802+ - "keep": Retain the compressors of the input array.
3803+ serializer : dict[str, JSON] | ArrayBytesCodec or "auto" or "keep", optional
37983804 Array-to-bytes codec to use for encoding the array data.
37993805 Zarr format 3 only. Zarr format 2 arrays use implicit array-to-bytes conversion.
38003806
38013807 If no ``serializer`` is provided, defaults to the serializer of the input array.
3808+ - "auto": Automatically determine the serializer based on the array's dtype.
3809+ - "keep": Retain the serializer of the input array.
38023810 fill_value : Any, optional
38033811 Fill value for the array.
38043812 If not specified, defaults to the fill value of the data array.
@@ -3843,23 +3851,31 @@ async def from_array(
38433851 #TODO
38443852 """
38453853
3846- # fill missing arguments with metadata of data Array
3847- if chunks == "auto" :
3854+ if chunks == "keep" :
38483855 chunks = data .chunks
3849- if filters is None :
3850- filters = data .filters
3851- if compressors is None :
3852- compressors = data .compressors
3856+ if zarr_format is None :
3857+ zarr_format = data .metadata .zarr_format
3858+ if filters == "keep" :
3859+ if zarr_format == data .metadata .zarr_format :
3860+ filters = data .filters
3861+ else :
3862+ filters = "auto"
3863+ if compressors == "keep" :
3864+ if zarr_format == data .metadata .zarr_format :
3865+ compressors = data .compressors
3866+ else :
3867+ compressors = "auto"
3868+ if serializer == "keep" :
3869+ if zarr_format == 3 :
3870+ serializer = cast (SerializerLike , data .serializer )
3871+ else :
3872+ serializer = "auto"
38533873 if fill_value is None :
38543874 fill_value = data .fill_value
38553875 if order is None :
38563876 order = data .order
3857- if zarr_format is None :
3858- zarr_format = data .metadata .zarr_format
3859- if zarr_format == 3 and serializer == "auto" :
3860- serializer = cast (SerializerLike , data .serializer )
38613877 if chunk_key_encoding is None and zarr_format == data .metadata .zarr_format :
3862- if data . metadata . zarr_format == 2 :
3878+ if zarr_format == 2 :
38633879 chunk_key_encoding = {"name" : "v2" , "separator" : data .metadata .dimension_separator }
38643880 else :
38653881 chunk_key_encoding = data .metadata .chunk_key_encoding
0 commit comments