Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ extend-select = [
ignore = [
"ANN401",
"PT011", # TODO: apply this rule
"PT030", # TODO: apply this rule
"RET505",
"RET506",
"RUF005",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def test_tree() -> None:
g3.create_group("baz")
g5 = g3.create_group("qux")
g5.create_array("baz", shape=(100,), chunks=(10,), dtype="float64")
with pytest.warns(DeprecationWarning): # noqa: PT031
with pytest.warns(DeprecationWarning, match=r"Group\.tree instead\."): # noqa: PT031
assert repr(zarr.tree(g1)) == repr(g1.tree())
assert str(zarr.tree(g1)) == str(g1.tree())

Expand Down
10 changes: 8 additions & 2 deletions tests/test_codecs/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,10 @@ def test_invalid_metadata(store: Store) -> None:
],
)
spath7 = StorePath(store, "warning_inefficient_codecs")
with pytest.warns(UserWarning):
with pytest.warns(
UserWarning,
match="Combining a `sharding_indexed` codec disables partial reads and writes, which may lead to inefficient performance",
):
Array.create(
spath7,
shape=(16, 16),
Expand All @@ -372,7 +375,10 @@ def test_invalid_metadata(store: Store) -> None:
@pytest.mark.parametrize("store", ["local", "memory"], indirect=["store"])
def test_invalid_metadata_create_array(store: Store) -> None:
spath = StorePath(store, "warning_inefficient_codecs")
with pytest.warns(UserWarning):
with pytest.warns(
UserWarning,
match="codec disables partial reads and writes, which may lead to inefficient performance",
):
zarr.create_array(
spath,
shape=(16, 16),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class NewCodec2(BytesCodec):

# warning because multiple implementations are available but none is selected in the config
register_codec("new_codec", NewCodec2)
with pytest.warns(UserWarning):
with pytest.warns(UserWarning, match="not configured in config. Selecting any implementation"):
get_codec_class("new_codec")

# no warning if multiple implementations are available and one is selected in the config
Expand Down
18 changes: 12 additions & 6 deletions tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ def test_group_create_array(
array = group.create_array(name=name, shape=shape, dtype=dtype)
array[:] = data
elif method == "array":
with pytest.warns(DeprecationWarning):
with pytest.warns(DeprecationWarning, match=r"Group\.create_array instead\."):
array = group.array(name=name, data=data, shape=shape, dtype=dtype)
else:
raise AssertionError
Expand All @@ -660,7 +660,7 @@ def test_group_create_array(
a[:] = data
elif method == "array":
with pytest.raises(ContainsArrayError): # noqa: PT012
with pytest.warns(DeprecationWarning):
with pytest.warns(DeprecationWarning, match=r"Group\.create_array instead\."):
a = group.array(name=name, shape=shape, dtype=dtype)
a[:] = data

Expand Down Expand Up @@ -1184,22 +1184,28 @@ def test_create_dataset_with_data(store: Store, zarr_format: ZarrFormat) -> None
"""
root = Group.from_store(store=store, zarr_format=zarr_format)
arr = np.random.random((5, 5))
with pytest.warns(DeprecationWarning):
with pytest.warns(DeprecationWarning, match=r"Group\.create_array instead\."):
data = root.create_dataset("random", data=arr, shape=arr.shape)
np.testing.assert_array_equal(np.asarray(data), arr)


async def test_create_dataset(store: Store, zarr_format: ZarrFormat) -> None:
root = await AsyncGroup.from_store(store=store, zarr_format=zarr_format)
with pytest.warns(DeprecationWarning):
with pytest.warns(DeprecationWarning, match=r"Group\.create_array instead\."):
foo = await root.create_dataset("foo", shape=(10,), dtype="uint8")
assert foo.shape == (10,)

with pytest.raises(ContainsArrayError), pytest.warns(DeprecationWarning):
with (
pytest.raises(ContainsArrayError),
pytest.warns(DeprecationWarning, match=r"Group\.create_array instead\."),
):
await root.create_dataset("foo", shape=(100,), dtype="int8")

_ = await root.create_group("bar")
with pytest.raises(ContainsGroupError), pytest.warns(DeprecationWarning):
with (
pytest.raises(ContainsGroupError),
pytest.warns(DeprecationWarning, match=r"Group\.create_array instead\."),
):
await root.create_dataset("bar", shape=(100,), dtype="int8")


Expand Down
Loading