Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0c8e7f7
WIP - backwards compat
TomAugspurger Aug 18, 2024
fa9e51d
fixup put
TomAugspurger Aug 19, 2024
8fdb605
rm consolidated
TomAugspurger Aug 19, 2024
0ac17cc
typing fixup
TomAugspurger Aug 19, 2024
be2b3cd
revert unneded change
TomAugspurger Aug 19, 2024
94933b3
fixup
TomAugspurger Aug 19, 2024
44ad6c7
deprecate positional args
TomAugspurger Aug 28, 2024
08e7f3c
attribute
TomAugspurger Aug 28, 2024
f937468
Fixup
TomAugspurger Aug 29, 2024
784cb28
Merge remote-tracking branch 'upstream/v3' into user/tom/fix/v2-compat
TomAugspurger Sep 3, 2024
b01e61c
Merge remote-tracking branch 'upstream/v3' into user/tom/fix/v2-compat
TomAugspurger Sep 6, 2024
c519fbe
fixup
TomAugspurger Sep 6, 2024
46c2c11
fixup
TomAugspurger Sep 6, 2024
1933f57
fixup
TomAugspurger Sep 6, 2024
36a2ceb
fixup
TomAugspurger Sep 6, 2024
1ae1cfd
fixup
TomAugspurger Sep 6, 2024
9f5429f
fixup
TomAugspurger Sep 6, 2024
a5ad0ca
fixup
TomAugspurger Sep 6, 2024
3d04845
Merge remote-tracking branch 'upstream/v3' into user/tom/fix/v2-compat
TomAugspurger Sep 16, 2024
b710c64
fixup
TomAugspurger Sep 16, 2024
0ab29d1
fixup
TomAugspurger Sep 16, 2024
aa1e3bc
fixup
TomAugspurger Sep 16, 2024
fb4bb85
fixup
TomAugspurger Sep 16, 2024
1cc84ab
fixup
TomAugspurger Sep 16, 2024
559399e
ci
TomAugspurger Sep 16, 2024
16bad38
Merge remote-tracking branch 'upstream/v3' into user/tom/fix/v2-compat
TomAugspurger Sep 19, 2024
f7f8457
Merge branch 'v3' into user/tom/fix/v2-compat
jhamman Sep 19, 2024
56431fe
Merge remote-tracking branch 'upstream/v3' into user/tom/fix/v2-compat
TomAugspurger Sep 19, 2024
b13dee3
fixup
TomAugspurger Sep 19, 2024
348aed8
Merge remote-tracking branch 'upstream/v3' into user/tom/fix/v2-compat
TomAugspurger Sep 20, 2024
2327141
fixup
TomAugspurger Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/v3' into user/tom/fix/v2-compat
  • Loading branch information
TomAugspurger committed Sep 16, 2024
commit 3d048457e357de5c8867c80ab834958db67fc3ae
7 changes: 5 additions & 2 deletions src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ async def group(
async def open_group(
store: StoreLike | None = None,
*, # Note: this is a change from v2
mode: AccessModeLiteral | None = None, # not used
mode: AccessModeLiteral | None = None,
cache_attrs: bool | None = None, # not used, default changed
synchronizer: Any = None, # not used
path: str | None = None,
Expand Down Expand Up @@ -562,7 +562,10 @@ async def open_group(
return await AsyncGroup.open(store_path, zarr_format=zarr_format)
except (KeyError, FileNotFoundError):
return await AsyncGroup.from_store(
store_path, zarr_format=zarr_format, exists_ok=True, attributes=attributes
store_path,
zarr_format=zarr_format or _default_zarr_version(),
exists_ok=True,
attributes=attributes,
)


Expand Down
1 change: 1 addition & 0 deletions tests/v3/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from zarr import Array, Group
from zarr.abc.store import Store
from zarr.api.synchronous import create, group, load, open, open_group, save, save_array, save_group
from zarr.core.common import ZarrFormat
from zarr.store.memory import MemoryStore


Expand Down
35 changes: 34 additions & 1 deletion tests/v3/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import pytest

from zarr import Array, Group
from zarr import Array, AsyncArray, Group
from zarr.core.buffer.cpu import NDBuffer
from zarr.core.common import ZarrFormat
from zarr.errors import ContainsArrayError, ContainsGroupError
Expand Down Expand Up @@ -178,3 +178,36 @@ def test_selection_positional_args_deprecated() -> None:

with pytest.warns(FutureWarning, match="Pass"):
arr.set_block_selection((0, slice(None)), 1, None)


@pytest.mark.parametrize("store", ("local",), indirect=["store"])
@pytest.mark.parametrize("zarr_format", (2, 3))
async def test_serializable_async_array(
store: LocalStore | MemoryStore, zarr_format: ZarrFormat
) -> None:
expected = await AsyncArray.create(
store=store, shape=(100,), chunks=(10,), zarr_format=zarr_format, dtype="i4"
)
# await expected.setitems(list(range(100)))

p = pickle.dumps(expected)
actual = pickle.loads(p)

assert actual == expected
# np.testing.assert_array_equal(await actual.getitem(slice(None)), await expected.getitem(slice(None)))
# TODO: uncomment the parts of this test that will be impacted by the config/prototype changes in flight


@pytest.mark.parametrize("store", ("local",), indirect=["store"])
@pytest.mark.parametrize("zarr_format", (2, 3))
def test_serializable_sync_array(store: LocalStore, zarr_format: ZarrFormat) -> None:
expected = Array.create(
store=store, shape=(100,), chunks=(10,), zarr_format=zarr_format, dtype="i4"
)
expected[:] = list(range(100))

p = pickle.dumps(expected)
actual = pickle.loads(p)

assert actual == expected
np.testing.assert_array_equal(actual[:], expected[:])
25 changes: 19 additions & 6 deletions tests/v3/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ async def test_asyncgroup_attrs(store: Store, zarr_format: ZarrFormat) -> None:
assert agroup.attrs == agroup.metadata.attributes == attributes


async def test_asyncgroup_info(store: LocalStore | MemoryStore, zarr_format: ZarrFormat) -> None:
async def test_asyncgroup_info(store: Store, zarr_format: ZarrFormat) -> None:
agroup = await AsyncGroup.from_store( # noqa
store,
zarr_format=zarr_format,
Expand Down Expand Up @@ -581,7 +581,10 @@ async def test_asyncgroup_getitem(store: Store, zarr_format: ZarrFormat) -> None
await agroup.getitem("foo")


async def test_asyncgroup_delitem(store: LocalStore | MemoryStore, zarr_format: ZarrFormat) -> None:
async def test_asyncgroup_delitem(store: Store, zarr_format: ZarrFormat) -> None:
if not store.supports_deletes:
pytest.skip("store does not support deletes")

agroup = await AsyncGroup.from_store(store=store, zarr_format=zarr_format)
array_name = "sub_array"
_ = await agroup.create_array(
Expand Down Expand Up @@ -690,7 +693,7 @@ async def test_serializable_async_group(store: LocalStore, zarr_format: ZarrForm
assert actual == expected


async def test_require_group(store: LocalStore | MemoryStore, zarr_format: ZarrFormat) -> None:
async def test_require_group(store: Store, zarr_format: ZarrFormat) -> None:
root = await AsyncGroup.from_store(store=store, zarr_format=zarr_format)

# create foo group
Expand Down Expand Up @@ -718,7 +721,7 @@ async def test_require_group(store: LocalStore | MemoryStore, zarr_format: ZarrF
await foo_group.require_group("bar")


async def test_require_groups(store: LocalStore | MemoryStore, zarr_format: ZarrFormat) -> None:
async def test_require_groups(store: Store, zarr_format: ZarrFormat) -> None:
root = await AsyncGroup.from_store(store=store, zarr_format=zarr_format)
# create foo group
_ = await root.create_group("foo", attributes={"foo": 100})
Expand All @@ -739,7 +742,7 @@ async def test_require_groups(store: LocalStore | MemoryStore, zarr_format: Zarr
assert no_group == ()


async def test_create_dataset(store: LocalStore | MemoryStore, zarr_format: ZarrFormat) -> None:
async def test_create_dataset(store: Store, zarr_format: ZarrFormat) -> None:
root = await AsyncGroup.from_store(store=store, zarr_format=zarr_format)
foo = await root.create_dataset("foo", shape=(10,), dtype="uint8")
assert foo.shape == (10,)
Expand All @@ -752,7 +755,7 @@ async def test_create_dataset(store: LocalStore | MemoryStore, zarr_format: Zarr
await root.create_dataset("bar", shape=(100,), dtype="int8")


async def test_require_array(store: LocalStore | MemoryStore, zarr_format: ZarrFormat) -> None:
async def test_require_array(store: Store, zarr_format: ZarrFormat) -> None:
root = await AsyncGroup.from_store(store=store, zarr_format=zarr_format)
foo1 = await root.require_array("foo", shape=(10,), dtype="i8", attributes={"foo": 101})
assert foo1.attrs == {"foo": 101}
Expand All @@ -775,3 +778,13 @@ async def test_require_array(store: LocalStore | MemoryStore, zarr_format: ZarrF
_ = await root.create_group("bar")
with pytest.raises(TypeError, match="Incompatible object"):
await root.require_array("bar", shape=(10,), dtype="int8")


@pytest.mark.parametrize("store", ("local",), indirect=["store"])
@pytest.mark.parametrize("zarr_format", (2, 3))
def test_serializable_sync_group(store: LocalStore, zarr_format: ZarrFormat) -> None:
expected = Group.create(store=store, attributes={"foo": 999}, zarr_format=zarr_format)
p = pickle.dumps(expected)
actual = pickle.loads(p)

assert actual == expected
You are viewing a condensed version of this merge commit. You can view the full changes here.