1010from typing_extensions import deprecated
1111
1212from zarr .core .array import Array , AsyncArray , get_array_metadata
13+ from zarr .core .array_spec import ArrayConfig , ArrayConfigParams
1314from zarr .core .buffer import NDArrayLike
1415from zarr .core .common import (
1516 JSON ,
@@ -812,6 +813,7 @@ async def create(
812813 codecs : Iterable [Codec | dict [str , JSON ]] | None = None ,
813814 dimension_names : Iterable [str ] | None = None ,
814815 storage_options : dict [str , Any ] | None = None ,
816+ config : ArrayConfig | ArrayConfigParams | None = None ,
815817 ** kwargs : Any ,
816818) -> AsyncArray [ArrayV2Metadata ] | AsyncArray [ArrayV3Metadata ]:
817819 """Create an array.
@@ -858,9 +860,10 @@ async def create(
858860 These defaults can be changed by modifying the value of ``array.v2_default_compressor`` in :mod:`zarr.core.config`. fill_value : object
859861 Default value to use for uninitialized portions of the array.
860862 order : {'C', 'F'}, optional
861- Deprecated in favor of the `array.order` configuration variable.
863+ Deprecated in favor of the ``config`` keyword argument.
864+ Pass ``{'order': <value>}`` to ``create`` instead of using this parameter.
862865 Memory layout to be used within each chunk.
863- If not specified, default is taken from the Zarr config ``` array.order``` .
866+ If not specified, the `` array.order`` parameter in the global config will be used .
864867 store : Store or str
865868 Store or path to directory in file system or name of zip file.
866869 synchronizer : object, optional
@@ -894,32 +897,26 @@ async def create(
894897 Separator placed between the dimensions of a chunk.
895898 V2 only. V3 arrays should use ``chunk_key_encoding`` instead.
896899 Default is ".".
897- .. versionadded:: 2.8
898-
899900 write_empty_chunks : bool, optional
900- Deprecated in favor of the `array.write_empty_chunks` configuration variable .
901-
902- If True (default) , all chunks will be stored regardless of their
901+ Deprecated in favor of the ``config`` keyword argument .
902+ Pass ``{'write_empty_chunks': <value>}`` to ``create`` instead of using this parameter.
903+ If True, all chunks will be stored regardless of their
903904 contents. If False, each chunk is compared to the array's fill value
904905 prior to storing. If a chunk is uniformly equal to the fill value, then
905906 that chunk is not be stored, and the store entry for that chunk's key
906- is deleted. This setting enables sparser storage, as only chunks with
907- non-fill-value data are stored, at the expense of overhead associated
908- with checking the data of each chunk.
909-
910- .. versionadded:: 2.11
911-
907+ is deleted.
912908 zarr_format : {2, 3, None}, optional
913909 The zarr format to use when saving.
914910 Default is 3.
915911 meta_array : array-like, optional
916912 An array instance to use for determining arrays to create and return
917913 to users. Use `numpy.empty(())` by default.
918-
919- .. versionadded:: 2.13
920914 storage_options : dict
921915 If using an fsspec URL to create the store, these will be passed to
922916 the backend implementation. Ignored otherwise.
917+ config : ArrayConfig or ArrayConfigParams, optional
918+ Runtime configuration of the array. If provided, will override the
919+ default values from `zarr.config.array`.
923920
924921 Returns
925922 -------
@@ -973,6 +970,30 @@ async def create(
973970 if mode is None :
974971 mode = "a"
975972 store_path = await make_store_path (store , path = path , mode = mode , storage_options = storage_options )
973+
974+ config_dict : ArrayConfigParams = {}
975+
976+ if write_empty_chunks is not None :
977+ if config is not None :
978+ msg = (
979+ "Both write_empty_chunks and config keyword arguments are set. "
980+ "This is redundant. When both are set, write_empty_chunks will be ignored and "
981+ "config will be used."
982+ )
983+ warnings .warn (UserWarning (msg ), stacklevel = 1 )
984+ config_dict ["write_empty_chunks" ] = write_empty_chunks
985+ if order is not None :
986+ if config is not None :
987+ msg = (
988+ "Both order and config keyword arguments are set. "
989+ "This is redundant. When both are set, order will be ignored and "
990+ "config will be used."
991+ )
992+ warnings .warn (UserWarning (msg ), stacklevel = 1 )
993+ config_dict ["order" ] = order
994+
995+ config_parsed = ArrayConfig .from_dict (config_dict )
996+
976997 return await AsyncArray .create (
977998 store_path ,
978999 shape = shape ,
@@ -989,8 +1010,7 @@ async def create(
9891010 codecs = codecs ,
9901011 dimension_names = dimension_names ,
9911012 attributes = attributes ,
992- order = order ,
993- write_empty_chunks = write_empty_chunks ,
1013+ config = config_parsed ,
9941014 ** kwargs ,
9951015 )
9961016
0 commit comments