@@ -2249,22 +2249,24 @@ def create_array(
22492249 self ,
22502250 name : str ,
22512251 * ,
2252- shape : ShapeLike ,
2253- dtype : npt .DTypeLike ,
2252+ shape : ShapeLike | None = None ,
2253+ dtype : npt .DTypeLike | None = None ,
2254+ data : np .ndarray [Any , np .dtype [Any ]] | None = None ,
22542255 chunks : ChunkCoords | Literal ["auto" ] = "auto" ,
22552256 shards : ShardsLike | None = None ,
22562257 filters : FiltersLike = "auto" ,
22572258 compressors : CompressorsLike = "auto" ,
22582259 compressor : CompressorLike = "auto" ,
22592260 serializer : SerializerLike = "auto" ,
22602261 fill_value : Any | None = 0 ,
2261- order : MemoryOrder | None = "C" ,
2262+ order : MemoryOrder | None = None ,
22622263 attributes : dict [str , JSON ] | None = None ,
2263- chunk_key_encoding : ChunkKeyEncoding | ChunkKeyEncodingLike | None = None ,
2264+ chunk_key_encoding : ChunkKeyEncodingLike | None = None ,
22642265 dimension_names : Iterable [str ] | None = None ,
22652266 storage_options : dict [str , Any ] | None = None ,
22662267 overwrite : bool = False ,
22672268 config : ArrayConfig | ArrayConfigLike | None = None ,
2269+ write_data : bool = True ,
22682270 ) -> Array :
22692271 """Create an array within this group.
22702272
@@ -2275,10 +2277,13 @@ def create_array(
22752277 name : str
22762278 The name of the array relative to the group. If ``path`` is ``None``, the array will be located
22772279 at the root of the store.
2278- shape : ChunkCoords
2279- Shape of the array.
2280- dtype : npt.DTypeLike
2281- Data type of the array.
2280+ shape : ChunkCoords, optional
2281+ Shape of the array. Can be ``None`` if ``data`` is provided.
2282+ dtype : npt.DTypeLike | None
2283+ Data type of the array. Can be ``None`` if ``data`` is provided.
2284+ data : Array-like data to use for initializing the array. If this parameter is provided, the
2285+ ``shape`` and ``dtype`` parameters must be identical to ``data.shape`` and ``data.dtype``,
2286+ or ``None``.
22822287 chunks : ChunkCoords, optional
22832288 Chunk shape of the array.
22842289 If not specified, default are guessed based on the shape and dtype.
@@ -2352,6 +2357,11 @@ def create_array(
23522357 Whether to overwrite an array with the same name in the store, if one exists.
23532358 config : ArrayConfig or ArrayConfigLike, optional
23542359 Runtime configuration for the array.
2360+ write_data : bool
2361+ If a pre-existing array-like object was provided to this function via the ``data`` parameter
2362+ then ``write_data`` determines whether the values in that array-like object should be
2363+ written to the Zarr array created by this function. If ``write_data`` is ``False``, then the
2364+ array will be left empty.
23552365
23562366 Returns
23572367 -------
@@ -2366,6 +2376,7 @@ def create_array(
23662376 name = name ,
23672377 shape = shape ,
23682378 dtype = dtype ,
2379+ data = data ,
23692380 chunks = chunks ,
23702381 shards = shards ,
23712382 fill_value = fill_value ,
@@ -2379,6 +2390,7 @@ def create_array(
23792390 overwrite = overwrite ,
23802391 storage_options = storage_options ,
23812392 config = config ,
2393+ write_data = write_data ,
23822394 )
23832395 )
23842396 )
0 commit comments