@@ -946,15 +946,17 @@ def create_array(
946946
947947 Examples
948948 --------
949- >>> import zarr
950- >>> store = zarr.storage.MemoryStore()
951- >>> arr = await zarr.create_array(
952- >>> store=store,
953- >>> shape=(100,100),
954- >>> chunks=(10,10),
955- >>> dtype='i4',
956- >>> fill_value=0)
957- <Array memory://140349042942400 shape=(100, 100) dtype=int32>
949+ ```python
950+ import zarr
951+ store = zarr.storage.MemoryStore()
952+ arr = zarr.create_array(
953+ store=store,
954+ shape=(100,100),
955+ chunks=(10,10),
956+ dtype='i4',
957+ fill_value=0)
958+ # <Array memory://... shape=(100, 100) dtype=int32>
959+ ```
958960 """
959961 return Array (
960962 sync (
@@ -1132,49 +1134,64 @@ def from_array(
11321134
11331135 Examples
11341136 --------
1135- Create an array from an existing Array::
1136-
1137- >>> import zarr
1138- >>> store = zarr.storage.MemoryStore()
1139- >>> store2 = zarr.storage.LocalStore('example.zarr')
1140- >>> arr = zarr.create_array(
1141- >>> store=store,
1142- >>> shape=(100,100),
1143- >>> chunks=(10,10),
1144- >>> dtype='int32',
1145- >>> fill_value=0)
1146- >>> arr2 = zarr.from_array(store2, data=arr)
1147- <Array file://example.zarr shape=(100, 100) dtype=int32>
1148-
1149- Create an array from an existing NumPy array::
1150-
1151- >>> import numpy as np
1152- >>> arr3 = zarr.from_array(
1153- zarr.storage.MemoryStore(),
1154- >>> data=np.arange(10000, dtype='i4').reshape(100, 100),
1155- >>> )
1156- <Array memory://125477403529984 shape=(100, 100) dtype=int32>
1157-
1158- Create an array from any array-like object::
1159-
1160- >>> arr4 = zarr.from_array(
1161- >>> zarr.storage.MemoryStore(),
1162- >>> data=[[1, 2], [3, 4]],
1163- >>> )
1164- <Array memory://125477392154368 shape=(2, 2) dtype=int64>
1165- >>> arr4[...]
1166- array([[1, 2],[3, 4]])
1167-
1168- Create an array from an existing Array without copying the data::
1169-
1170- >>> arr5 = zarr.from_array(
1171- >>> zarr.storage.MemoryStore(),
1172- >>> data=arr4,
1173- >>> write_data=False,
1174- >>> )
1175- <Array memory://140678602965568 shape=(2, 2) dtype=int64>
1176- >>> arr5[...]
1177- array([[0, 0],[0, 0]])
1137+ Create an array from an existing Array:
1138+
1139+ ```python
1140+ import zarr
1141+ store = zarr.storage.MemoryStore()
1142+ store2 = zarr.storage.LocalStore('example_from_array.zarr')
1143+ arr = zarr.create_array(
1144+ store=store,
1145+ shape=(100,100),
1146+ chunks=(10,10),
1147+ dtype='int32',
1148+ fill_value=0)
1149+ arr2 = zarr.from_array(store2, data=arr, overwrite=True)
1150+ # <Array file://example_from_array.zarr shape=(100, 100) dtype=int32>
1151+ ```
1152+
1153+ Create an array from an existing NumPy array:
1154+
1155+ ```python
1156+ import zarr
1157+ import numpy as np
1158+ arr3 = zarr.from_array(
1159+ zarr.storage.MemoryStore(),
1160+ data=np.arange(10000, dtype='i4').reshape(100, 100),
1161+ )
1162+ # <Array memory://... shape=(100, 100) dtype=int32>
1163+ ```
1164+
1165+ Create an array from any array-like object:
1166+
1167+ ```python
1168+ import zarr
1169+ arr4 = zarr.from_array(
1170+ zarr.storage.MemoryStore(),
1171+ data=[[1, 2], [3, 4]],
1172+ )
1173+ # <Array memory://... shape=(2, 2) dtype=int64>
1174+ arr4[...]
1175+ # array([[1, 2],[3, 4]])
1176+ ```
1177+
1178+ Create an array from an existing Array without copying the data:
1179+
1180+ ```python
1181+ import zarr
1182+ arr4 = zarr.from_array(
1183+ zarr.storage.MemoryStore(),
1184+ data=[[1, 2], [3, 4]],
1185+ )
1186+ arr5 = zarr.from_array(
1187+ zarr.storage.MemoryStore(),
1188+ data=arr4,
1189+ write_data=False,
1190+ )
1191+ # <Array memory://... shape=(2, 2) dtype=int64>
1192+ arr5[...]
1193+ # array([[0, 0],[0, 0]])
1194+ ```
11781195 """
11791196 return Array (
11801197 sync (
0 commit comments