Skip to content

Commit ddc0935

Browse files
committed
Merge remote-tracking branch 'upstream/main' into prefers-consolidated
2 parents 79d2c41 + 0713cfa commit ddc0935

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

changes/3127.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
When `zarr.save` has an argument `path=some/path/` and multiple arrays in `args`, the path resulted in `some/path/some/path` due to using the `path`
2+
argument twice while building the array path. This is now fixed.

docs/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ def skip_submodules(
106106
"installation": "user-guide/installation.html",
107107
"api": "api/zarr/index",
108108
"release": "release-notes.html",
109-
"release-notes": "release-notes.html"
110109
}
111110

112111
# The language for content autogenerated by Sphinx. Refer to documentation

src/zarr/api/asynchronous.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,13 +513,12 @@ async def save_group(
513513
raise ValueError("at least one array must be provided")
514514
aws = []
515515
for i, arr in enumerate(args):
516-
_path = f"{path}/arr_{i}" if path is not None else f"arr_{i}"
517516
aws.append(
518517
save_array(
519518
store_path,
520519
arr,
521520
zarr_format=zarr_format,
522-
path=_path,
521+
path=f"arr_{i}",
523522
storage_options=storage_options,
524523
)
525524
)

tests/test_api.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,22 +229,23 @@ async def test_open_group_unspecified_version(
229229
@pytest.mark.parametrize("store", ["local", "memory", "zip"], indirect=["store"])
230230
@pytest.mark.parametrize("n_args", [10, 1, 0])
231231
@pytest.mark.parametrize("n_kwargs", [10, 1, 0])
232-
def test_save(store: Store, n_args: int, n_kwargs: int) -> None:
232+
@pytest.mark.parametrize("path", [None, "some_path"])
233+
def test_save(store: Store, n_args: int, n_kwargs: int, path: None | str) -> None:
233234
data = np.arange(10)
234235
args = [np.arange(10) for _ in range(n_args)]
235236
kwargs = {f"arg_{i}": data for i in range(n_kwargs)}
236237

237238
if n_kwargs == 0 and n_args == 0:
238239
with pytest.raises(ValueError):
239-
save(store)
240+
save(store, path=path)
240241
elif n_args == 1 and n_kwargs == 0:
241-
save(store, *args)
242-
array = zarr.api.synchronous.open(store)
242+
save(store, *args, path=path)
243+
array = zarr.api.synchronous.open(store, path=path)
243244
assert isinstance(array, Array)
244245
assert_array_equal(array[:], data)
245246
else:
246-
save(store, *args, **kwargs) # type: ignore [arg-type]
247-
group = zarr.api.synchronous.open(store)
247+
save(store, *args, path=path, **kwargs) # type: ignore [arg-type]
248+
group = zarr.api.synchronous.open(store, path=path)
248249
assert isinstance(group, Group)
249250
for array in group.array_values():
250251
assert_array_equal(array[:], data)
@@ -384,8 +385,8 @@ def test_array_order_warns(order: MemoryOrder | None, zarr_format: ZarrFormat) -
384385
# assert "LazyLoader: " in repr(loader)
385386

386387

387-
def test_load_array(memory_store: Store) -> None:
388-
store = memory_store
388+
def test_load_array(sync_store: Store) -> None:
389+
store = sync_store
389390
foo = np.arange(100)
390391
bar = np.arange(100, 0, -1)
391392
save(store, foo=foo, bar=bar)

tests/test_store/test_memory.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import pytest
99

1010
import zarr
11-
import zarr.core
12-
import zarr.core.array
1311
from zarr.core.buffer import Buffer, cpu, gpu
1412
from zarr.storage import GpuMemoryStore, MemoryStore
1513
from zarr.testing.store import StoreTests

0 commit comments

Comments
 (0)