Skip to content

Commit 9d505a6

Browse files
committed
fix and supress some test warnings
1 parent 4d8bbee commit 9d505a6

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

xarray/tests/test_backends.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4185,7 +4185,7 @@ def test_phony_dims_warning(self) -> None:
41854185
fx.create_dataset(k, data=v)
41864186
with pytest.warns(UserWarning, match="The 'phony_dims' kwarg"):
41874187
with xr.open_dataset(tmp_file, engine="h5netcdf", group="bar") as ds:
4188-
assert ds.dims == {
4188+
assert ds.sizes == {
41894189
"phony_dim_0": 5,
41904190
"phony_dim_1": 5,
41914191
"phony_dim_2": 5,
@@ -4300,7 +4300,8 @@ def test_open_fileobj(self) -> None:
43004300
# `raises_regex`?). Ref https://github.com/pydata/xarray/pull/5191
43014301
with open(tmp_file, "rb") as f:
43024302
f.seek(8)
4303-
open_dataset(f)
4303+
with open_dataset(f): # ensure file gets closed
4304+
pass
43044305

43054306

43064307
@requires_h5netcdf
@@ -6587,11 +6588,11 @@ def test_h5netcdf_storage_options() -> None:
65876588
ds2.to_netcdf(f2, engine="h5netcdf")
65886589

65896590
files = [f"file://{f}" for f in [f1, f2]]
6590-
ds = xr.open_mfdataset(
6591+
with xr.open_mfdataset(
65916592
files,
65926593
engine="h5netcdf",
65936594
concat_dim="time",
65946595
combine="nested",
65956596
storage_options={"skip_instance_cache": False},
6596-
)
6597-
assert_identical(xr.concat([ds1, ds2], dim="time"), ds)
6597+
) as ds:
6598+
assert_identical(xr.concat([ds1, ds2], dim="time"), ds)

xarray/tests/test_computation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ def test_apply_groupby_add() -> None:
634634
add(data_array.groupby("y"), data_array.groupby("x"))
635635

636636

637+
@pytest.mark.filterwarnings("ignore:Duplicate dimension names present")
637638
def test_unified_dim_sizes() -> None:
638639
assert unified_dim_sizes([xr.Variable((), 0)]) == {}
639640
assert unified_dim_sizes([xr.Variable("x", [1]), xr.Variable("x", [1])]) == {"x": 1}

xarray/tests/test_variable.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2952,7 +2952,8 @@ def test_from_sparse(self, Var):
29522952
import sparse
29532953

29542954
arr = np.diagflat([1, 2, 3])
2955-
sparr = sparse.COO(coords=[[0, 1, 2], [0, 1, 2]], data=[1, 2, 3])
2955+
coords = np.array([[0, 1, 2], [0, 1, 2]])
2956+
sparr = sparse.COO(coords=coords, data=[1, 2, 3], shape=(3, 3))
29562957
v = Variable(["x", "y"], sparr)
29572958

29582959
assert_identical(v.as_numpy(), Variable(["x", "y"], arr))

0 commit comments

Comments
 (0)