Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence upstream Zarr warnings #9920

Merged
merged 2 commits into from
Jan 2, 2025
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
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ filterwarnings = [
"default:the `pandas.MultiIndex` object:FutureWarning:xarray.tests.test_variable",
"default:Using a non-tuple sequence for multidimensional indexing is deprecated:FutureWarning",
"default:Duplicate dimension names present:UserWarning:xarray.namedarray.core",

# TODO: this is raised for vlen-utf8, consolidated metadata, U1 dtype
"ignore:is currently not part .* the Zarr version 3 specification.",
# TODO: remove once we know how to deal with a changed signature in protocols
"default:::xarray.tests.test_strategies",
]
Expand Down
24 changes: 18 additions & 6 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2435,10 +2435,16 @@ def test_warning_on_bad_chunks(self) -> None:
for chunks in good_chunks:
kwargs = {"chunks": chunks}
with assert_no_warnings():
with self.roundtrip(original, open_kwargs=kwargs) as actual:
for k, v in actual.variables.items():
# only index variables should be in memory
assert v._in_memory == (k in actual.dims)
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
message=".*Zarr version 3 specification.*",
category=UserWarning,
)
with self.roundtrip(original, open_kwargs=kwargs) as actual:
for k, v in actual.variables.items():
# only index variables should be in memory
assert v._in_memory == (k in actual.dims)

@requires_dask
def test_deprecate_auto_chunk(self) -> None:
Expand Down Expand Up @@ -2985,8 +2991,14 @@ def test_save_emptydim(self, chunk) -> None:
def test_no_warning_from_open_emptydim_with_chunks(self) -> None:
ds = Dataset({"x": (("a", "b"), np.empty((5, 0)))}).chunk({"a": 1})
with assert_no_warnings():
with self.roundtrip(ds, open_kwargs=dict(chunks={"a": 1})) as ds_reload:
assert_identical(ds, ds_reload)
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
message=".*Zarr version 3 specification.*",
category=UserWarning,
)
with self.roundtrip(ds, open_kwargs=dict(chunks={"a": 1})) as ds_reload:
assert_identical(ds, ds_reload)

@pytest.mark.parametrize("consolidated", [False, True, None])
@pytest.mark.parametrize("compute", [False, True])
Expand Down
2 changes: 2 additions & 0 deletions xarray/tests/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,7 @@ def test_0d_str(self):
assert v.dtype == np.dtype("S3")
assert v.values == "foo".encode("ascii")

@pytest.mark.filterwarnings("ignore:Converting non-nanosecond")
def test_0d_datetime(self):
v = Variable([], pd.Timestamp("2000-01-01"))
assert v.dtype == np.dtype("datetime64[ns]")
Expand Down Expand Up @@ -1954,6 +1955,7 @@ def test_big_endian_reduce(self):
expected = Variable([], 5)
assert_identical(expected, v.sum())

@pytest.mark.filterwarnings("ignore:Converting non-nanosecond")
def test_reduce_funcs(self):
v = Variable("x", np.array([1, np.nan, 2, 3]))
assert_identical(v.mean(), Variable([], 2))
Expand Down
Loading