Skip to content

Commit 28b46fe

Browse files
Add more docstrings
1 parent dacb27a commit 28b46fe

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/zarr/core/array.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,26 @@ def from_dict(
11181118
store_path: StorePath,
11191119
data: dict[str, JSON],
11201120
) -> Array:
1121+
"""
1122+
Create a Zarr array from a dictionary.
1123+
1124+
Parameters
1125+
----------
1126+
store_path : StorePath
1127+
The path within the store where the array should be created.
1128+
1129+
data : dict of str to JSON
1130+
A dictionary representing the array data and metadata in JSON-serializable format.
1131+
Returns
1132+
-------
1133+
AsyncArray
1134+
The created Zarr array.
1135+
1136+
Raises
1137+
------
1138+
ValueError
1139+
If the provided dictionary is not compatible with the Zarr array format.
1140+
"""
11211141
async_array = AsyncArray.from_dict(store_path=store_path, data=data)
11221142
return cls(async_array)
11231143

@@ -2606,6 +2626,30 @@ def resize(self, new_shape: ChunkCoords) -> Array:
26062626
)
26072627

26082628
def update_attributes(self, new_attributes: dict[str, JSON]) -> Array:
2629+
"""
2630+
Update the array's attributes.
2631+
2632+
Parameters
2633+
----------
2634+
new_attributes : dict of str to JSON
2635+
A dictionary of new attributes to update or add to the array. The keys represent attribute
2636+
names, and the values must be JSON-compatible.
2637+
2638+
Returns
2639+
-------
2640+
Array
2641+
The array with the updated attributes.
2642+
2643+
Raises
2644+
------
2645+
ValueError
2646+
If the attributes are invalid or incompatible with the array's metadata.
2647+
2648+
Notes
2649+
-----
2650+
- The updated attributes will be merged with existing attributes, and any conflicts will be
2651+
overwritten by the new values.
2652+
"""
26092653
return type(self)(
26102654
sync(
26112655
self._async_array.update_attributes(new_attributes),

0 commit comments

Comments
 (0)