Skip to content

Commit 38aee40

Browse files
committed
fix argument order in calls of from_array
1 parent edd4852 commit 38aee40

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

src/zarr/api/asynchronous.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ async def array(
546546
"""
547547

548548
if isinstance(data, Array):
549-
return await from_array(data, **kwargs)
549+
return await from_array(data=data, **kwargs)
550550

551551
# ensure data is array-like
552552
if not hasattr(data, "shape") or not hasattr(data, "dtype"):

src/zarr/api/synchronous.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,23 +1062,23 @@ def from_array(
10621062
>>> chunks=(10,10),
10631063
>>> dtype='int32',
10641064
>>> fill_value=0)
1065-
>>> arr2 = zarr.from_array(arr, store=store2)
1065+
>>> arr2 = zarr.from_array(store2, data=arr)
10661066
<Array file://example.zarr shape=(100, 100) dtype=int32>
10671067
10681068
Create an array from an existing NumPy array::
10691069
10701070
>>> import numpy as np
10711071
>>> arr3 = zarr.from_array(
1072-
>>> np.arange(10000, dtype='i4').reshape(100, 100),
1073-
>>> store=zarr.storage.MemoryStore(),
1072+
zarr.storage.MemoryStore(),
1073+
>>> data=np.arange(10000, dtype='i4').reshape(100, 100),
10741074
>>> )
10751075
<Array memory://125477403529984 shape=(100, 100) dtype=int32>
10761076
10771077
Create an array from any array-like object::
10781078
10791079
>>> arr4 = zarr.from_array(
1080-
>>> [[1, 2], [3, 4]],
1081-
>>> store= zarr.storage.MemoryStore(),
1080+
>>> zarr.storage.MemoryStore(),
1081+
>>> data=[[1, 2], [3, 4]],
10821082
>>> )
10831083
<Array memory://125477392154368 shape=(2, 2) dtype=int64>
10841084
>>> arr4[...]
@@ -1087,8 +1087,8 @@ def from_array(
10871087
Create an array from an existing Array without copying the data::
10881088
10891089
>>> arr5 = zarr.from_array(
1090-
>>> arr4,
1091-
>>> store=zarr.storage.MemoryStore(),
1090+
>>> zarr.storage.MemoryStore(),
1091+
>>> data=arr4,
10921092
>>> write_data=False,
10931093
>>> )
10941094
<Array memory://140678602965568 shape=(2, 2) dtype=int64>
@@ -1098,9 +1098,9 @@ def from_array(
10981098
return Array(
10991099
sync(
11001100
zarr.core.array.from_array(
1101-
data,
11021101
store,
1103-
write_data,
1102+
data=data,
1103+
write_data=write_data,
11041104
name=name,
11051105
chunks=chunks,
11061106
shards=shards,

src/zarr/core/array.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3948,22 +3948,22 @@ async def from_array(
39483948
>>> chunks=(10,10),
39493949
>>> dtype='int32',
39503950
>>> fill_value=0)
3951-
>>> arr2 = await zarr.api.asynchronous.from_array(arr, store=store2)
3951+
>>> arr2 = await zarr.api.asynchronous.from_array(store2, data=arr)
39523952
<AsyncArray file://example.zarr shape=(100, 100) dtype=int32>
39533953
39543954
Create an array from an existing NumPy array::
39553955
39563956
>>> arr3 = await zarr.api.asynchronous.from_array(
3957-
>>> np.arange(10000, dtype='i4').reshape(100, 100),
3958-
>>> store=zarr.storage.MemoryStore(),
3957+
>>> zarr.storage.MemoryStore(),
3958+
>>> data=np.arange(10000, dtype='i4').reshape(100, 100),
39593959
>>> )
39603960
<AsyncArray memory://123286956732800 shape=(100, 100) dtype=int32>
39613961
39623962
Create an array from any array-like object::
39633963
39643964
>>> arr4 = await zarr.api.asynchronous.from_array(
3965-
>>> [[1, 2], [3, 4]],
3966-
>>> store=zarr.storage.MemoryStore(),
3965+
>>> zarr.storage.MemoryStore(),
3966+
>>> data=[[1, 2], [3, 4]],
39673967
>>> )
39683968
<AsyncArray memory://123286959761024 shape=(2, 2) dtype=int64>
39693969
>>> await arr4.getitem(...)
@@ -3972,8 +3972,8 @@ async def from_array(
39723972
Create an array from an existing Array without copying the data::
39733973
39743974
>>> arr5 = await zarr.api.asynchronous.from_array(
3975-
>>> Array(arr4),
3976-
>>> store=zarr.storage.MemoryStore(),
3975+
>>> zarr.storage.MemoryStore(),
3976+
>>> data=Array(arr4),
39773977
>>> write_data=False,
39783978
>>> )
39793979
<AsyncArray memory://140678602965568 shape=(2, 2) dtype=int64>
@@ -4429,8 +4429,8 @@ async def create_array(
44294429
)
44304430
if data_parsed is not None:
44314431
return await from_array(
4432+
store,
44324433
data=data_parsed,
4433-
store=store,
44344434
write_data=write_data,
44354435
name=name,
44364436
chunks=chunks,

tests/test_array.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,8 +1357,8 @@ async def test_creation_from_other_zarr_format(
13571357

13581358
src[:] = np.arange(50 * 50).reshape((50, 50))
13591359
result = zarr.from_array(
1360-
src,
13611360
store=store2,
1361+
data=src,
13621362
zarr_format=new_format,
13631363
)
13641364
np.testing.assert_array_equal(result[:], src[:])
@@ -1408,7 +1408,7 @@ async def test_from_array(
14081408
new_attributes: dict[str, JSON] = {"foo": "bar"}
14091409

14101410
result = zarr.from_array(
1411-
src,
1411+
data=src,
14121412
store=store2,
14131413
chunks=new_chunks,
14141414
fill_value=new_fill_value,
@@ -1443,7 +1443,7 @@ async def test_from_array_arraylike(
14431443
) -> None:
14441444
fill_value = 42
14451445
result = zarr.from_array(
1446-
src, store=store, chunks=chunks, write_data=write_data, fill_value=fill_value
1446+
store, data=src, chunks=chunks, write_data=write_data, fill_value=fill_value
14471447
)
14481448
if write_data:
14491449
np.testing.assert_array_equal(result[...], np.array(src))

0 commit comments

Comments
 (0)