Skip to content

Commit 1622499

Browse files
authored
Silence upstream Zarr warnings (#9920)
1 parent 3fd79ac commit 1622499

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ filterwarnings = [
336336
"default:the `pandas.MultiIndex` object:FutureWarning:xarray.tests.test_variable",
337337
"default:Using a non-tuple sequence for multidimensional indexing is deprecated:FutureWarning",
338338
"default:Duplicate dimension names present:UserWarning:xarray.namedarray.core",
339-
339+
# TODO: this is raised for vlen-utf8, consolidated metadata, U1 dtype
340+
"ignore:is currently not part .* the Zarr version 3 specification.",
340341
# TODO: remove once we know how to deal with a changed signature in protocols
341342
"default:::xarray.tests.test_strategies",
342343
]

xarray/tests/test_backends.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -2435,10 +2435,16 @@ def test_warning_on_bad_chunks(self) -> None:
24352435
for chunks in good_chunks:
24362436
kwargs = {"chunks": chunks}
24372437
with assert_no_warnings():
2438-
with self.roundtrip(original, open_kwargs=kwargs) as actual:
2439-
for k, v in actual.variables.items():
2440-
# only index variables should be in memory
2441-
assert v._in_memory == (k in actual.dims)
2438+
with warnings.catch_warnings():
2439+
warnings.filterwarnings(
2440+
"ignore",
2441+
message=".*Zarr version 3 specification.*",
2442+
category=UserWarning,
2443+
)
2444+
with self.roundtrip(original, open_kwargs=kwargs) as actual:
2445+
for k, v in actual.variables.items():
2446+
# only index variables should be in memory
2447+
assert v._in_memory == (k in actual.dims)
24422448

24432449
@requires_dask
24442450
def test_deprecate_auto_chunk(self) -> None:
@@ -2985,8 +2991,14 @@ def test_save_emptydim(self, chunk) -> None:
29852991
def test_no_warning_from_open_emptydim_with_chunks(self) -> None:
29862992
ds = Dataset({"x": (("a", "b"), np.empty((5, 0)))}).chunk({"a": 1})
29872993
with assert_no_warnings():
2988-
with self.roundtrip(ds, open_kwargs=dict(chunks={"a": 1})) as ds_reload:
2989-
assert_identical(ds, ds_reload)
2994+
with warnings.catch_warnings():
2995+
warnings.filterwarnings(
2996+
"ignore",
2997+
message=".*Zarr version 3 specification.*",
2998+
category=UserWarning,
2999+
)
3000+
with self.roundtrip(ds, open_kwargs=dict(chunks={"a": 1})) as ds_reload:
3001+
assert_identical(ds, ds_reload)
29903002

29913003
@pytest.mark.parametrize("consolidated", [False, True, None])
29923004
@pytest.mark.parametrize("compute", [False, True])

xarray/tests/test_variable.py

+2
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ def test_0d_str(self):
11081108
assert v.dtype == np.dtype("S3")
11091109
assert v.values == "foo".encode("ascii")
11101110

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

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

0 commit comments

Comments
 (0)