zarr.api.asynchronous
zarr.api.asynchronous ¶
__all__
module-attribute
¶
__all__ = [
"array",
"consolidate_metadata",
"copy",
"copy_all",
"copy_store",
"create",
"create_array",
"create_hierarchy",
"empty",
"empty_like",
"from_array",
"full",
"full_like",
"group",
"load",
"ones",
"ones_like",
"open",
"open_array",
"open_consolidated",
"open_group",
"open_like",
"save",
"save_array",
"save_group",
"tree",
"zeros",
"zeros_like",
]
array
async
¶
Create an array filled with data.
Parameters:
-
data(array_like) –The data to fill the array with.
-
**kwargs(Any, default:{}) –Passed through to
create.
Returns:
-
array(array) –The new array.
Source code in src/zarr/api/asynchronous.py
consolidate_metadata
async
¶
consolidate_metadata(
store: StoreLike,
path: str | None = None,
zarr_format: ZarrFormat | None = None,
) -> AsyncGroup
Consolidate the metadata of all nodes in a hierarchy.
Upon completion, the metadata of the root node in the Zarr hierarchy will be
updated to include all the metadata of child nodes. For Stores that do
not support consolidated metadata, this operation raises a TypeError.
Parameters:
-
store(StoreLike) –The store-like object whose metadata you wish to consolidate. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
path(str, default:None) –A path to a group in the store to consolidate at. Only children below that group will be consolidated.
By default, the root node is used so all the metadata in the store is consolidated.
-
zarr_format((2, 3, None), default:2) –The zarr format of the hierarchy. By default the zarr format is inferred.
Returns:
-
group(AsyncGroup) –The group, with the
consolidated_metadatafield set to include the metadata of each child node. If the Store doesn't support consolidated metadata, this function raises aTypeError. SeeStore.supports_consolidated_metadata.
Source code in src/zarr/api/asynchronous.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
copy
async
¶
copy_all
async
¶
copy_store
async
¶
create
async
¶
create(
shape: tuple[int, ...] | int,
*,
chunks: ChunksLike | None = None,
dtype: ZDTypeLike | None = None,
compressor: CompressorLike = "auto",
fill_value: Any | None = DEFAULT_FILL_VALUE,
order: MemoryOrder | None = None,
store: StoreLike | None = None,
synchronizer: Any | None = None,
overwrite: bool = False,
path: PathLike | None = None,
chunk_store: StoreLike | None = None,
filters: Iterable[dict[str, JSON] | Numcodec]
| None = None,
cache_metadata: bool | None = None,
cache_attrs: bool | None = None,
read_only: bool | None = None,
object_codec: Codec | None = None,
dimension_separator: Literal[".", "/"] | None = None,
write_empty_chunks: bool | None = None,
zarr_format: ZarrFormat | None = None,
meta_array: Any | None = None,
attributes: dict[str, JSON] | None = None,
chunk_shape: ChunksLike | None = None,
chunk_key_encoding: ChunkKeyEncoding
| tuple[Literal["default"], Literal[".", "/"]]
| tuple[Literal["v2"], Literal[".", "/"]]
| None = None,
codecs: Iterable[Codec | dict[str, JSON]] | None = None,
dimension_names: DimensionNamesLike = None,
storage_options: dict[str, Any] | None = None,
config: ArrayConfigLike | None = None,
mode: AccessModeLiteral | None = None,
data: ArrayLike | None = None,
) -> AnyAsyncArray
Create an array.
Parameters:
-
shape(int or tuple of ints) –Array shape.
-
chunks(ChunksLike, default:None) –Chunk shape. If None (the default), it is guessed from
shapeanddtype. If False, it is set toshape, i.e., a single chunk for the whole array. If an int, the chunk size in each dimension is given by the value ofchunks.Trueis not a chunk shape and raises aValueError. -
dtype(str or dtype, default:None) –NumPy dtype.
-
compressor(Codec, default:'auto') –Primary compressor to compress chunk data. Zarr format 2 only. Zarr format 3 arrays should use
codecsinstead.If neither
compressornorfiltersare provided, the default compressorzarr.codecs.ZstdCodecis used.If
compressoris set toNone, no compression is used. -
fill_value(Any, default:DEFAULT_FILL_VALUE) –Fill value for the array.
-
order(('C', 'F'), default:'C') –Deprecated in favor of the
configkeyword argument. Pass{'order': <value>}tocreateinstead of using this parameter. Memory layout to be used within each chunk. If not specified, thearray.orderparameter in the global config will be used. -
store(StoreLike or None, default:None) –StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
synchronizer(object, default:None) –Array synchronizer.
-
overwrite(bool, default:False) –If True, delete all pre-existing data in
storeatpathbefore creating the array. -
path(str, default:None) –Path under which array is stored.
-
chunk_store(StoreLike or None, default:None) –Separate storage for chunks. If not provided,
storewill be used for storage of both chunks and metadata. -
filters(Iterable[Codec] | Literal['auto'], default:None) –Iterable of filters to apply to each chunk of the array, in order, before serializing that chunk to bytes.
For Zarr format 3, a "filter" is a codec that takes an array and returns an array, and these values must be instances of
zarr.abc.codec.ArrayArrayCodec, or a dict representations ofzarr.abc.codec.ArrayArrayCodec.For Zarr format 2, a "filter" can be any numcodecs codec; you should ensure that the order of your filters is consistent with the behavior of each filter.
The default value of
"auto"instructs Zarr to use a default based on the data type of the array and the Zarr format specified. For all data types in Zarr V3, and most data types in Zarr V2, the default filters are empty. The only cases where default filters are not empty is when the Zarr format is 2, and the data type is a variable-length data type likezarr.dtype.VariableLengthUTF8orzarr.dtype.VariableLengthBytes. In these cases, the default filters contains a single element which is a codec specific to that particular data type.To create an array with no filters, provide an empty iterable or the value
None. -
cache_metadata(bool, default:None) –If True, array configuration metadata will be cached for the lifetime of the object. If False, array metadata will be reloaded prior to all data access and modification operations (may incur overhead depending on storage and data access pattern).
-
cache_attrs(bool, default:None) –If True (default), user attributes will be cached for attribute read operations. If False, user attributes are reloaded from the store prior to all attribute read operations.
-
read_only(bool, default:None) –True if array should be protected against modification.
-
object_codec(Codec, default:None) –A codec to encode object arrays, only needed if dtype=object.
-
dimension_separator(('.', '/'), default:'.') –Separator placed between the dimensions of a chunk. Zarr format 2 only. Zarr format 3 arrays should use
chunk_key_encodinginstead. -
write_empty_chunks(bool, default:None) –Deprecated in favor of the
configkeyword argument. Pass{'write_empty_chunks': <value>}tocreateinstead of using this parameter. If True, all chunks will be stored regardless of their contents. If False, each chunk is compared to the array's fill value prior to storing. If a chunk is uniformly equal to the fill value, then that chunk is not be stored, and the store entry for that chunk's key is deleted. -
zarr_format((2, 3, None), default:2) –The Zarr format to use when creating an array. The default is
None, which instructs Zarr to choose the default Zarr format value defined in the runtime configuration. -
meta_array(array - like, default:None) –Not implemented.
-
attributes(dict[str, JSON], default:None) –A dictionary of user attributes to store with the array.
-
chunk_shape(ChunksLike, default:None) –The shape of the Array's chunks (default is None). Zarr format 3 only. Zarr format 2 arrays should use
chunksinstead. -
chunk_key_encoding(ChunkKeyEncoding, default:None) –A specification of how the chunk keys are represented in storage. Zarr format 3 only. Zarr format 2 arrays should use
dimension_separatorinstead. Default is("default", "/"). -
codecs(Sequence of Codecs or dicts, default:None) –An iterable of Codec or dict serializations of Codecs. Zarr V3 only.
The elements of
codecsspecify the transformation from array values to stored bytes. Zarr format 3 only. Zarr format 2 arrays should usefiltersandcompressorinstead.If no codecs are provided, default codecs will be used based on the data type of the array. For most data types, the default codecs are the tuple
(BytesCodec(), ZstdCodec()); data types that require a specialzarr.abc.codec.ArrayBytesCodec, like variable-length strings or bytes, will use thezarr.abc.codec.ArrayBytesCodecrequired for the data type instead ofzarr.codecs.BytesCodec. -
dimension_names(Iterable[str | None] | None = None, default:None) –An iterable of dimension names. Zarr format 3 only.
-
storage_options(dict, default:None) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
-
config(ArrayConfigLike, default:None) –Runtime configuration of the array. If provided, will override the default values from
zarr.config.array. -
mode(('r', 'r+', 'a', 'w', 'w-'), default:'r') –Legacy way to control overwriting, kept for compatibility with Zarr-Python 2. Prefer
overwrite. The access mode used to openstore; the default,None, is'a'.'a'and'r+'create the array and fail if a node exists atpath, unlessoverwriteisTrue.'w'replaces anything stored underpath(the whole store ifpathis not set), even ifoverwriteisFalse. On a store that cannot delete keys,'w'raises an error instead of replacing an existing node.'w-'fails if anything is stored underpath, even ifoverwriteisTrue.'r'always fails.
If
storeis aStorePath,modeis not validated against it:'w'still setsoverwrite, and the other modes have no effect. -
data(array - like, default:None) –Values written into the new array after it is created. Unlike the
dataparameter ofcreate_array, it does not set the shape or data type of the array. To create an array from existing data, usecreate_array(data=...). A Zarr array is not supported asdata.
Returns:
-
z(array) –The array.
Source code in src/zarr/api/asynchronous.py
918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 | |
create_array
async
¶
create_array(
store: StoreLike,
*,
name: str | None = None,
shape: ShapeLike | None = None,
dtype: ZDTypeLike | None = None,
data: ndarray[Any, dtype[Any]] | None = None,
chunks: ChunksLike | Literal["auto"] = "auto",
shards: ShardsLike | None = None,
filters: FiltersLike = "auto",
compressors: CompressorsLike = "auto",
serializer: SerializerLike = "auto",
fill_value: Any | None = DEFAULT_FILL_VALUE,
order: MemoryOrder | None = None,
zarr_format: ZarrFormat | None = 3,
attributes: dict[str, JSON] | None = None,
chunk_key_encoding: ChunkKeyEncodingLike | None = None,
dimension_names: DimensionNamesLike = None,
storage_options: dict[str, Any] | None = None,
overwrite: bool = False,
config: ArrayConfigLike | None = None,
write_data: bool = True,
) -> AnyAsyncArray
Create an array.
Parameters:
-
store(StoreLike) –StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
name(str or None, default:None) –The name of the array within the store. If
nameisNone, the array will be located at the root of the store. -
shape(ShapeLike, default:None) –Shape of the array. Must be
Noneifdatais provided. -
dtype(ZDTypeLike | None, default:None) –Data type of the array. Must be
Noneifdatais provided. -
data(ndarray, default:None) –Array-like data to use for initializing the array. If this parameter is provided, the
shapeanddtypeparameters must beNone. -
chunks(tuple[int, ...] | Sequence[Sequence[int]] | Literal['auto'], default:"auto") –Chunk shape of the array. If chunks is "auto", a chunk shape is guessed based on the shape of the array and the dtype. A nested list of per-dimension edge sizes creates a rectilinear grid. Rectilinear chunk grids are experimental and must be explicitly enabled with
zarr.config.set({'array.rectilinear_chunks': True})while the feature is stabilizing. -
shards(tuple[int, ...], default:None) –Shard shape of the array. The default value of
Noneresults in no sharding at all. -
filters(Iterable[Codec] | Literal['auto'], default:'auto') –Iterable of filters to apply to each chunk of the array, in order, before serializing that chunk to bytes.
For Zarr format 3, a "filter" is a codec that takes an array and returns an array, and these values must be instances of
zarr.abc.codec.ArrayArrayCodec, or a dict representations ofzarr.abc.codec.ArrayArrayCodec.For Zarr format 2, a "filter" can be any numcodecs codec; you should ensure that the order of your filters is consistent with the behavior of each filter.
The default value of
"auto"instructs Zarr to use a default based on the data type of the array and the Zarr format specified. For all data types in Zarr V3, and most data types in Zarr V2, the default filters are empty. The only cases where default filters are not empty is when the Zarr format is 2, and the data type is a variable-length data type likezarr.dtype.VariableLengthUTF8orzarr.dtype.VariableLengthBytes. In these cases, the default filters contains a single element which is a codec specific to that particular data type.To create an array with no filters, provide an empty iterable or the value
None. -
compressors(Iterable[Codec], default:'auto') –List of compressors to apply to the array. Compressors are applied in order, and after any filters are applied (if any are specified) and the data is serialized into bytes.
For Zarr format 3, a "compressor" is a codec that takes a bytestream, and returns another bytestream. Multiple compressors may be provided for Zarr format 3. If no
compressorsare provided, a default set of compressors will be used. These defaults can be changed by modifying the value ofarray.v3_default_compressorsinzarr.config. UseNoneto omit default compressors.For Zarr format 2, a "compressor" can be any numcodecs codec. Only a single compressor may be provided for Zarr format 2. If no
compressoris provided, a default compressor will be used. This default can be changed by modifying the value ofarray.v2_default_compressorinzarr.config. UseNoneto omit the default compressor. -
serializer(dict[str, JSON] | ArrayBytesCodec, default:'auto') –Array-to-bytes codec to use for encoding the array data. Zarr format 3 only. Zarr format 2 arrays use implicit array-to-bytes conversion. If no
serializeris provided, a default serializer will be used. These defaults can be changed by modifying the value ofarray.v3_default_serializerinzarr.config. -
fill_value(Any, default:DEFAULT_FILL_VALUE) –Fill value for the array.
-
order(('C', 'F'), default:"C") –The memory order of the array (default is "C"). For Zarr format 2, this parameter sets the memory order of the array. For Zarr format 3, this parameter is deprecated, because memory order is a runtime parameter for Zarr format 3 arrays. The recommended way to specify the memory order for Zarr format 3 arrays is via the
configparameter, e.g.{'config': 'C'}. If noorderis provided, a default order will be used. This default can be changed by modifying the value ofarray.orderinzarr.config. -
zarr_format((2, 3), default:2) –The zarr format to use when saving.
-
attributes(dict, default:None) –Attributes for the array.
-
chunk_key_encoding(ChunkKeyEncodingLike, default:None) –A specification of how the chunk keys are represented in storage. For Zarr format 3, the default is
{"name": "default", "separator": "/"}. For Zarr format 2, the default is{"name": "v2", "separator": "."}. -
dimension_names(Iterable[str], default:None) –The names of the dimensions (default is None). Zarr format 3 only. Zarr format 2 arrays should not use this parameter.
-
storage_options(dict, default:None) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
-
overwrite(bool, default:False) –Whether to overwrite an array with the same name in the store, if one exists. If
True, any existing keys under that path are deleted first. -
config(ArrayConfigLike, default:None) –Runtime configuration for the array.
-
write_data(bool, default:True) –If a pre-existing array-like object was provided to this function via the
dataparameter thenwrite_datadetermines whether the values in that array-like object should be written to the Zarr array created by this function. Ifwrite_dataisFalse, then the array will be left empty.
Returns:
-
AsyncArray–The array.
Examples:
>>> import asyncio
>>> import zarr
>>> asyncio.run(
... zarr.api.asynchronous.create_array(
... store={},
... shape=(100,100),
... chunks=(10,10),
... dtype="i4",
... fill_value=0
... )
... )
<AsyncArray memory://... shape=(100, 100) dtype=int32>
Source code in src/zarr/core/array.py
4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 | |
create_group
async
¶
create_group(
*,
store: StoreLike,
path: str | None = None,
overwrite: bool = False,
zarr_format: ZarrFormat | None = None,
attributes: dict[str, Any] | None = None,
storage_options: dict[str, Any] | None = None,
) -> AsyncGroup
Create a group.
Parameters:
-
store(StoreLike) –StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
path(str, default:None) –Group path within store.
-
overwrite(bool, default:False) –If True, pre-existing data at
pathwill be deleted before creating the group. -
zarr_format((2, 3, None), default:2) –The zarr format to use when saving. If no
zarr_formatis provided, the default format will be used. This default can be changed by modifying the value ofdefault_zarr_formatinzarr.config. -
storage_options(dict, default:None) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
Returns:
-
AsyncGroup–The new group.
Source code in src/zarr/api/asynchronous.py
create_hierarchy
async
¶
create_hierarchy(
*,
store: Store,
nodes: dict[
str,
GroupMetadata | ArrayV2Metadata | ArrayV3Metadata,
],
overwrite: bool = False,
) -> AsyncIterator[tuple[str, AsyncGroup | AnyAsyncArray]]
Create a complete zarr hierarchy from a collection of metadata objects.
This function will parse its input to ensure that the hierarchy is complete. Any implicit groups
will be inserted as needed. For example, an input like
{'a/b': GroupMetadata} will be parsed to
{'': GroupMetadata, 'a': GroupMetadata, 'b': Groupmetadata}
After input parsing, this function then creates all the nodes in the hierarchy concurrently.
Arrays and Groups are yielded in the order they are created. This order is not stable and should not be relied on.
Parameters
Parameters
store : Store
The storage backend to use.
nodes : dict[str, GroupMetadata | ArrayV3Metadata | ArrayV2Metadata]
A dictionary defining the hierarchy. The keys are the paths of the nodes in the hierarchy,
relative to the root of the Store. The root of the store can be specified with the empty
string ''. The values are instances of GroupMetadata or ArrayMetadata. Note that
all values must have the same zarr_format -- it is an error to mix zarr versions in the
same hierarchy.
Leading "/" characters from keys will be removed.
overwrite : bool
Whether to overwrite existing nodes. Defaults to False, in which case an error is
raised instead of overwriting an existing array or group.
This function will not erase an existing group unless that group is explicitly named in
``nodes``. If ``nodes`` defines implicit groups, e.g. ``{`'a/b/c': GroupMetadata}``, and a
group already exists at path ``a``, then this function will leave the group at ``a`` as-is.
Yields:
-
tuple[str, AsyncGroup | AsyncArray]–Yields (path, node) pairs, in the order the nodes were created.
Examples:
>>> async def example():
... from zarr.api.asynchronous import create_hierarchy
... from zarr.core.group import GroupMetadata
... from zarr.storage import MemoryStore
...
... store = MemoryStore()
... nodes = {'a': GroupMetadata(attributes={'name': 'leaf'})}
... return sorted([x async for x in create_hierarchy(store=store, nodes=nodes)])
>>> import asyncio
>>> asyncio.run(example())
[('', <AsyncGroup memory://...>), ('a', <AsyncGroup memory://.../a>)]
Source code in src/zarr/core/group.py
3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 | |
empty
async
¶
Create an empty array with the specified shape. The contents will be filled with the specified fill value or zeros if no fill value is provided.
Parameters:
-
shape(int or tuple of int) –Shape of the empty array.
-
**kwargs(Any, default:{}) –Keyword arguments passed to
create.
Notes
The contents of an empty Zarr array are not defined. On attempting to retrieve data from an empty Zarr array, any values may be returned, and these are not guaranteed to be stable from one access to the next.
Source code in src/zarr/api/asynchronous.py
empty_like
async
¶
empty_like(
a: ArrayLike,
*,
zarr_format: ZarrFormat | None = None,
**kwargs: Any,
) -> AnyAsyncArray
Create an empty array like a. The contents will be filled with the
array's fill value or zeros if no fill value is provided.
Parameters:
-
a(array - like) –The array to create an empty array like.
-
zarr_format((2, 3, None), default:2) –The zarr format of the new array. If
None(default), the zarr format ofaif it is a zarr array, otherwise the default zarr format. -
**kwargs(Any, default:{}) –Keyword arguments passed to
create.
Returns:
-
Array–The new array.
Notes
The contents of an empty Zarr array are not defined. On attempting to retrieve data from an empty Zarr array, any values may be returned, and these are not guaranteed to be stable from one access to the next.
Source code in src/zarr/api/asynchronous.py
from_array
async
¶
from_array(
store: StoreLike,
*,
data: AnyArray | ArrayLike,
write_data: bool = True,
name: str | None = None,
chunks: ChunksLike | Literal["auto", "keep"] = "keep",
shards: ShardsLike | Literal["keep"] | None = "keep",
filters: FiltersLike | Literal["keep"] = "keep",
compressors: CompressorsLike | Literal["keep"] = "keep",
serializer: SerializerLike | Literal["keep"] = "keep",
fill_value: Any | None = DEFAULT_FILL_VALUE,
order: MemoryOrder | None = None,
zarr_format: ZarrFormat | None = None,
attributes: dict[str, JSON] | None = None,
chunk_key_encoding: ChunkKeyEncodingLike | None = None,
dimension_names: DimensionNamesLike = None,
storage_options: dict[str, Any] | None = None,
overwrite: bool = False,
config: ArrayConfigLike | None = None,
) -> AnyAsyncArray
Create an array from an existing array or array-like.
Parameters:
-
store(StoreLike) –StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
data(Array | array - like) –The array to copy.
-
write_data(bool, default:True) –Whether to copy the data from the input array to the new array. If
write_dataisFalse, the new array will be created with the same metadata as the input array, but without any data. -
name(str or None, default:None) –The name of the array within the store. If
nameisNone, the array will be located at the root of the store. -
chunks(tuple[int, ...] or Sequence[Sequence[int]] or 'auto' or 'keep', default:'keep') –Chunk shape of the array. Following values are supported:
- "auto": Automatically determine the chunk shape based on the array's shape and dtype.
- "keep": Retain the chunk grid of the data array if it is a zarr Array.
- tuple[int, ...]: A tuple of integers representing the chunk shape (regular grid).
- Sequence[Sequence[int]]: Per-dimension chunk edge lists (rectilinear grid).
Rectilinear chunk grids are experimental and must be explicitly enabled
with
zarr.config.set({'array.rectilinear_chunks': True})while the feature is stabilizing.
If not specified, defaults to "keep" if data is a zarr Array, otherwise "auto".
-
shards(tuple[int, ...], default:'keep') –Shard shape of the array. Following values are supported:
- "auto": Automatically determine the shard shape based on the array's shape and chunk shape.
- "keep": Retain the shard shape of the data array if it is a zarr Array.
- tuple[int, ...]: A tuple of integers representing the shard shape.
- None: No sharding.
If not specified, defaults to "keep" if data is a zarr Array, otherwise None.
-
filters(Iterable[Codec] | Literal['auto', 'keep'], default:'keep') –Iterable of filters to apply to each chunk of the array, in order, before serializing that chunk to bytes.
For Zarr format 3, a "filter" is a codec that takes an array and returns an array, and these values must be instances of
zarr.abc.codec.ArrayArrayCodec, or a dict representations ofzarr.abc.codec.ArrayArrayCodec.For Zarr format 2, a "filter" can be any numcodecs codec; you should ensure that the order of your filters is consistent with the behavior of each filter.
The default value of
"keep"instructs Zarr to inferfiltersfromdata. If that inference is not possible, Zarr will fall back to the behavior specified by"auto", which is to choose default filters based on the data type of the array and the Zarr format specified. For all data types in Zarr V3, and most data types in Zarr V2, the default filters are the empty tuple(). The only cases where default filters are not empty is when the Zarr format is 2, and the data type is a variable-length data type likezarr.dtype.VariableLengthUTF8orzarr.dtype.VariableLengthUTF8. In these cases, the default filters is a tuple with a single element which is a codec specific to that particular data type.To create an array with no filters, provide an empty iterable or the value
None. -
compressors(Iterable[Codec] or 'auto' or 'keep', default:'keep') –List of compressors to apply to the array. Compressors are applied in order, and after any filters are applied (if any are specified) and the data is serialized into bytes.
For Zarr format 3, a "compressor" is a codec that takes a bytestream, and returns another bytestream. Multiple compressors may be provided for Zarr format 3.
For Zarr format 2, a "compressor" can be any numcodecs codec. Only a single compressor may be provided for Zarr format 2.
Following values are supported:
- Iterable[Codec]: List of compressors to apply to the array.
- "auto": Automatically determine the compressors based on the array's dtype.
- "keep": Retain the compressors of the input array if it is a zarr Array.
If no
compressorsare provided, defaults to "keep" if data is a zarr Array, otherwise "auto". -
serializer(dict[str, JSON] | ArrayBytesCodec or 'auto' or 'keep', default:'keep') –Array-to-bytes codec to use for encoding the array data. Zarr format 3 only. Zarr format 2 arrays use implicit array-to-bytes conversion.
Following values are supported:
- dict[str, JSON]: A dict representation of an
ArrayBytesCodec. - ArrayBytesCodec: An instance of
ArrayBytesCodec. - "auto": a default serializer will be used. These defaults can be changed by modifying the value of
array.v3_default_serializerinzarr.config. - "keep": Retain the serializer of the input array if it is a zarr Array.
- dict[str, JSON]: A dict representation of an
-
fill_value(Any, default:DEFAULT_FILL_VALUE) –Fill value for the array. If not specified, defaults to the fill value of the data array. Pass
Noneexplicitly to use the default scalar of the data type (Zarr format 3) or a null fill value (Zarr format 2) instead. -
order(('C', 'F'), default:"C") –The memory order of the array (default is "C"). For Zarr format 2, this parameter sets the memory order of the array. For Zarr format 3, this parameter is deprecated, because memory order is a runtime parameter for Zarr format 3 arrays. The recommended way to specify the memory order for Zarr format 3 arrays is via the
configparameter, e.g.{'config': 'C'}. If not specified, defaults to the memory order of the data array. -
zarr_format((2, 3), default:2) –The zarr format to use when saving. If not specified, defaults to the zarr format of the data array.
-
attributes(dict, default:None) –Attributes for the array. If not specified, the source Zarr array's attributes are deep-copied so nested containers are independent. Deeply nested attributes can raise
RecursionErrorduring copying even if they can be stored and reopened; the threshold depends on Python's recursion limit and the current call stack. Pass an empty dict to create the array with no attributes. -
chunk_key_encoding(ChunkKeyEncoding, default:None) –A specification of how the chunk keys are represented in storage. For Zarr format 3, the default is
{"name": "default", "separator": "/"}. For Zarr format 2, the default is{"name": "v2", "separator": "."}. If not specified and the data array has the same zarr format as the target array, the chunk key encoding of the data array is used. -
dimension_names(Iterable[str | None] | None, default:None) –The names of the dimensions (default is None). Zarr format 3 only. Zarr format 2 arrays should not use this parameter. If not specified, defaults to the dimension names of the data array.
-
storage_options(dict, default:None) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
-
overwrite(bool, default:False) –Whether to overwrite an array with the same name in the store, if one exists.
-
config(ArrayConfig or ArrayConfigLike, default:None) –Runtime configuration for the array.
Returns:
-
AsyncArray–The array.
Examples:
Create an array from an existing Array:
>>> import asyncio
>>> import zarr
>>> store = zarr.storage.LocalStore("example.zarr")
>>> arr = zarr.create_array(
... store={},
... shape=(100,100),
... chunks=(10,10),
... dtype="int32",
... fill_value=0,
... )
>>> arr2 = asyncio.run(from_array(store, data=arr, overwrite=True))
>>> arr2
<AsyncArray file://example.zarr shape=(100, 100) dtype=int32>
>>> asyncio.run(store.clear()) # Remove files generated by test
Create an array from an existing NumPy array:
>>> arr3 = asyncio.run(
... from_array({}, data=np.arange(10000, dtype="i4").reshape(100, 100))
... )
>>> arr3
<AsyncArray memory://... shape=(100, 100) dtype=int32>
Create an array from any array-like object:
>>> arr4 = asyncio.run(from_array({}, data=[[1, 2], [3, 4]]))
>>> arr4
<AsyncArray memory://... shape=(2, 2) dtype=int64>
>>> asyncio.run(arr4.getitem(...))
array([[1, 2],
[3, 4]])
Create an array from an existing Array without copying the data:
>>> arr5 = asyncio.run(from_array({}, data=Array(arr4), write_data=False))
>>> arr5
<AsyncArray memory://... shape=(2, 2) dtype=int64>
>>> asyncio.run(arr5.getitem(...))
array([[0, 0],
[0, 0]])
Source code in src/zarr/core/array.py
4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 | |
full
async
¶
Create an array, with fill_value being used as the default value for
uninitialized portions of the array.
Parameters:
-
shape(int or tuple of int) –Shape of the empty array.
-
fill_value(scalar) –Fill value.
-
**kwargs(Any, default:{}) –Keyword arguments passed to
create.
Returns:
-
Array–The new array.
Source code in src/zarr/api/asynchronous.py
full_like
async
¶
full_like(
a: ArrayLike,
*,
zarr_format: ZarrFormat | None = None,
**kwargs: Any,
) -> AnyAsyncArray
Create a filled array like a.
Parameters:
-
a(array - like) –The array to create an empty array like.
-
zarr_format((2, 3, None), default:2) –The zarr format of the new array. If
None(default), the zarr format ofaif it is a zarr array, otherwise the default zarr format. -
**kwargs(Any, default:{}) –Keyword arguments passed to
zarr.api.asynchronous.create.
Returns:
-
Array–The new array.
Source code in src/zarr/api/asynchronous.py
group
async
¶
group(
*,
store: StoreLike | None = None,
overwrite: bool = False,
chunk_store: StoreLike | None = None,
cache_attrs: bool | None = None,
synchronizer: Any | None = None,
path: str | None = None,
zarr_format: ZarrFormat | None = None,
meta_array: Any | None = None,
attributes: dict[str, JSON] | None = None,
storage_options: dict[str, Any] | None = None,
) -> AsyncGroup
Create a group.
Parameters:
-
store(StoreLike or None, default:None) –StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
overwrite(bool, default:False) –If True, delete any pre-existing data in
storeatpathbefore creating the group. -
chunk_store(StoreLike or None, default:None) –Separate storage for chunks. Not implemented.
-
cache_attrs(bool, default:None) –If True (default), user attributes will be cached for attribute read operations. If False, user attributes are reloaded from the store prior to all attribute read operations.
-
synchronizer(object, default:None) –Array synchronizer.
-
path(str, default:None) –Group path within store.
-
meta_array(array - like, default:None) –An array instance to use for determining arrays to create and return to users. Use
numpy.empty(())by default. -
zarr_format((2, 3, None), default:2) –The zarr format to use when saving.
-
storage_options(dict, default:None) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
Returns:
-
g(group) –The new group.
Source code in src/zarr/api/asynchronous.py
load
async
¶
load(
*,
store: StoreLike,
path: str | None = None,
zarr_format: ZarrFormat | None = None,
) -> NDArrayLikeOrScalar | dict[str, NDArrayLikeOrScalar]
Load data from an array or group into memory.
Parameters:
-
store(StoreLike) –StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
path(str or None, default:None) –The path within the store from which to load.
Returns:
-
out–If the path contains an array, out will be a numpy array. If the path contains a group, out will be a dict-like object where keys are array names and values are numpy arrays.
See Also
save, open
Notes
If loading data from a group of arrays, data will not be immediately loaded into memory. Rather, arrays will be loaded into memory as they are requested.
Unlike open, which returns a lazy Array or
Group backed by the store, load eagerly reads the data and
returns it as an in-memory array (or a dict of arrays for a group).
The array type is NumPy by default, but follows the configured
buffer prototype (for example, CuPy for GPU use cases).
Use open when you want to read or write data incrementally without loading it
all into memory.
Source code in src/zarr/api/asynchronous.py
ones
async
¶
Create an array, with one being used as the default value for uninitialized portions of the array.
Parameters:
-
shape(int or tuple of int) –Shape of the empty array.
-
**kwargs(Any, default:{}) –Keyword arguments passed to
zarr.api.asynchronous.create.
Returns:
-
Array–The new array.
Source code in src/zarr/api/asynchronous.py
ones_like
async
¶
ones_like(
a: ArrayLike,
*,
zarr_format: ZarrFormat | None = None,
**kwargs: Any,
) -> AnyAsyncArray
Create an array of ones like a.
Parameters:
-
a(array - like) –The array to create an empty array like.
-
zarr_format((2, 3, None), default:2) –The zarr format of the new array. If
None(default), the zarr format ofaif it is a zarr array, otherwise the default zarr format. -
**kwargs(Any, default:{}) –Keyword arguments passed to
zarr.api.asynchronous.create.
Returns:
-
Array–The new array.
Source code in src/zarr/api/asynchronous.py
open
async
¶
open(
*,
store: StoreLike | None = None,
mode: AccessModeLiteral | None = None,
zarr_format: ZarrFormat | None = None,
path: str | None = None,
storage_options: dict[str, Any] | None = None,
**kwargs: Any,
) -> AnyAsyncArray | AsyncGroup
Convenience function to open a group or array using file-mode-like semantics.
Parameters:
-
store(StoreLike or None, default:None) –StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
mode(('r', 'r+', 'a', 'w', 'w-'), default:'r') –Persistence mode: 'r' means read only (must exist); 'r+' means read/write (must exist); 'a' means read/write (create if doesn't exist); 'w' means create (overwrite if exists); 'w-' means create (fail if exists). On a store that cannot delete keys, 'w' raises an error instead of replacing an existing node. If the store is read-only, the default is 'r'; otherwise, it is 'a'.
-
zarr_format((2, 3, None), default:2) –The zarr format to use when saving.
-
path(str or None, default:None) –The path within the store to open.
-
storage_options(dict, default:None) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
-
**kwargs(Any, default:{}) –Additional parameters are passed through to
zarr.open_arrayorzarr.open_group.
Returns:
See Also
load
Notes
open returns a lazy Array or Group backed by
the store, so data is read and written incrementally. Use load
instead when you want the data eagerly read into an in-memory array (a
NumPy array by default).
Source code in src/zarr/api/asynchronous.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
open_array
async
¶
open_array(
*,
store: StoreLike | None = None,
zarr_format: ZarrFormat | None = None,
path: PathLike = "",
storage_options: dict[str, Any] | None = None,
**kwargs: Any,
) -> AnyAsyncArray
Open an array using file-mode-like semantics.
Parameters:
-
store(StoreLike, default:None) –StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
zarr_format((2, 3, None), default:2) –The zarr format to use when saving.
-
path(str, default:'') –Path in store to array.
-
storage_options(dict, default:None) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
-
**kwargs(Any, default:{}) –Any keyword arguments to pass to
create.
Returns:
-
AsyncArray–The opened array.
Source code in src/zarr/api/asynchronous.py
open_consolidated
async
¶
open_consolidated(
*args: Any,
use_consolidated: Literal[True] = True,
**kwargs: Any,
) -> AsyncGroup
Alias for open_group with use_consolidated=True.
Source code in src/zarr/api/asynchronous.py
open_group
async
¶
open_group(
store: StoreLike | None = None,
*,
mode: AccessModeLiteral = "a",
cache_attrs: bool | None = None,
synchronizer: Any = None,
path: str | None = None,
chunk_store: StoreLike | None = None,
storage_options: dict[str, Any] | None = None,
zarr_format: ZarrFormat | None = None,
meta_array: Any | None = None,
attributes: dict[str, JSON] | None = None,
use_consolidated: bool | str | None = None,
) -> AsyncGroup
Open a group using file-mode-like semantics.
Parameters:
-
store(StoreLike or None, default:None) –StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
mode(('r', 'r+', 'a', 'w', 'w-'), default:'r') –Persistence mode: 'r' means read only (must exist); 'r+' means read/write (must exist); 'a' means read/write (create if doesn't exist); 'w' means create (overwrite if exists); 'w-' means create (fail if exists). On a store that cannot delete keys, 'w' raises an error instead of replacing an existing node.
-
cache_attrs(bool, default:None) –If True (default), user attributes will be cached for attribute read operations. If False, user attributes are reloaded from the store prior to all attribute read operations.
-
synchronizer(object, default:None) –Array synchronizer.
-
path(str, default:None) –Group path within store.
-
chunk_store(StoreLike or None, default:None) –Separate storage for chunks. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
storage_options(dict, default:None) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
-
meta_array(array - like, default:None) –An array instance to use for determining arrays to create and return to users. Use
numpy.empty(())by default. -
attributes(dict, default:None) –A dictionary of JSON-serializable values with user-defined attributes.
-
use_consolidated(bool or str, default:None) –Whether to use consolidated metadata.
By default, consolidated metadata is used if it's present in the store (in the
zarr.jsonfor Zarr format 3 and in the.zmetadatafile for Zarr format 2).To explicitly require consolidated metadata, set
use_consolidated=True, which will raise an exception if consolidated metadata is not found.To explicitly not use consolidated metadata, set
use_consolidated=False, which will fall back to using the regular, non consolidated metadata.Zarr format 2 allowed configuring the key storing the consolidated metadata (
.zmetadataby default). Specify the custom key asuse_consolidatedto load consolidated metadata from a non-default key.
Returns:
-
g(group) –The new group.
Source code in src/zarr/api/asynchronous.py
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | |
open_like
async
¶
open_like(
a: ArrayLike,
path: str,
*,
zarr_format: ZarrFormat | None = None,
**kwargs: Any,
) -> AnyAsyncArray
Open a persistent array like a.
Parameters:
-
a(Array) –The shape and data-type of a define these same attributes of the returned array.
-
path(str) –The path to the new array.
-
zarr_format((2, 3, None), default:2) –The zarr format of the array to open or create. If
None(default), an existing array of either format is opened, and a missing one is created in the default zarr format. The zarr format ofais not inherited. -
**kwargs(Any, default:{}) –Additional keyword arguments passed to
open_array. Ifmodeis omitted orNone, it defaults to"a". Passmode="r"when opening an existing array from a read-only store.
Returns:
-
AsyncArray–The opened array.
Source code in src/zarr/api/asynchronous.py
save
async
¶
save(
store: StoreLike,
*args: NDArrayLike,
zarr_format: ZarrFormat | None = None,
path: str | None = None,
storage_options: dict[str, Any] | None = None,
**kwargs: Any,
) -> None
Convenience function to save an array or group of arrays to the local file system.
Parameters:
-
store(StoreLike) –StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
*args(ndarray, default:()) –NumPy arrays with data to save.
-
zarr_format((2, 3, None), default:2) –The zarr format to use when saving.
-
path(str or None, default:None) –The path within the group where the arrays will be saved.
-
storage_options(dict, default:None) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
-
**kwargs(Any, default:{}) –NumPy arrays with data to save.
Source code in src/zarr/api/asynchronous.py
save_array
async
¶
save_array(
store: StoreLike,
arr: NDArrayLike,
*,
zarr_format: ZarrFormat | None = None,
path: str | None = None,
storage_options: dict[str, Any] | None = None,
**kwargs: Any,
) -> None
Convenience function to save a NumPy array to the local file system, following a similar API to the NumPy save() function.
Parameters:
-
store(StoreLike) –StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
arr(ndarray) –NumPy array with data to save.
-
zarr_format((2, 3, None), default:2) –The zarr format to use when saving. The default is
None, which will use the default Zarr format defined in the global configuration object. -
path(str or None, default:None) –The path within the store where the array will be saved.
-
storage_options(dict, default:None) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
-
**kwargs(Any, default:{}) –Passed through to
create, e.g., compressor.
Source code in src/zarr/api/asynchronous.py
save_group
async
¶
save_group(
store: StoreLike,
*args: NDArrayLike,
zarr_format: ZarrFormat | None = None,
path: str | None = None,
storage_options: dict[str, Any] | None = None,
**kwargs: NDArrayLike,
) -> None
Convenience function to save several NumPy arrays to the local file system, following a similar API to the NumPy savez()/savez_compressed() functions.
Parameters:
-
store(StoreLike) –StoreLike object to open. See the storage documentation in the user guide for a description of all valid StoreLike values.
-
*args(ndarray, default:()) –NumPy arrays with data to save.
-
zarr_format((2, 3, None), default:2) –The zarr format to use when saving.
-
path(str or None, default:None) –Path within the store where the group will be saved.
-
storage_options(dict, default:None) –If using an fsspec URL to create the store, these will be passed to the backend implementation. Ignored otherwise.
-
**kwargs(NDArrayLike, default:{}) –NumPy arrays with data to save.
Source code in src/zarr/api/asynchronous.py
tree
async
¶
tree(
grp: AsyncGroup,
expand: bool | None = None,
level: int | None = None,
) -> Any
Provide a rich display of the hierarchy.
Deprecated
zarr.tree() is deprecated since v3.0.0 and will be removed in a future release.
Use group.tree() instead.
Parameters:
-
grp(Group) –Zarr or h5py group.
-
expand(bool, default:None) –Only relevant for HTML representation. If True, tree will be fully expanded.
-
level(int, default:None) –Maximum depth to descend into hierarchy.
Returns:
-
TreeRepr–A pretty-printable object displaying the hierarchy.
Source code in src/zarr/api/asynchronous.py
zeros
async
¶
Create an array, with zero being used as the default value for uninitialized portions of the array.
Parameters:
-
shape(int or tuple of int) –Shape of the empty array.
-
**kwargs(Any, default:{}) –Keyword arguments passed to
zarr.api.asynchronous.create.
Returns:
-
Array–The new array.
Source code in src/zarr/api/asynchronous.py
zeros_like
async
¶
zeros_like(
a: ArrayLike,
*,
zarr_format: ZarrFormat | None = None,
**kwargs: Any,
) -> AnyAsyncArray
Create an array of zeros like a.
Parameters:
-
a(array - like) –The array to create an empty array like.
-
zarr_format((2, 3, None), default:2) –The zarr format of the new array. If
None(default), the zarr format ofaif it is a zarr array, otherwise the default zarr format. -
**kwargs(Any, default:{}) –Keyword arguments passed to
create.
Returns:
-
Array–The new array.