Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions xarray/tests/test_array_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def test_aggregation_skipna(arrays) -> None:
assert_equal(actual, expected)


# casting nan warns
@pytest.mark.filterwarnings("ignore:invalid value encountered in cast")
def test_astype(arrays) -> None:
np_arr, xp_arr = arrays
expected = np_arr.astype(np.int64)
Expand Down
11 changes: 6 additions & 5 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -4185,7 +4185,7 @@ def test_phony_dims_warning(self) -> None:
fx.create_dataset(k, data=v)
with pytest.warns(UserWarning, match="The 'phony_dims' kwarg"):
with xr.open_dataset(tmp_file, engine="h5netcdf", group="bar") as ds:
assert ds.dims == {
assert ds.sizes == {
"phony_dim_0": 5,
"phony_dim_1": 5,
"phony_dim_2": 5,
Expand Down Expand Up @@ -4300,7 +4300,8 @@ def test_open_fileobj(self) -> None:
# `raises_regex`?). Ref https://github.com/pydata/xarray/pull/5191
with open(tmp_file, "rb") as f:
f.seek(8)
open_dataset(f)
with open_dataset(f): # ensure file gets closed
pass


@requires_h5netcdf
Expand Down Expand Up @@ -6587,11 +6588,11 @@ def test_h5netcdf_storage_options() -> None:
ds2.to_netcdf(f2, engine="h5netcdf")

files = [f"file://{f}" for f in [f1, f2]]
ds = xr.open_mfdataset(
with xr.open_mfdataset(
files,
engine="h5netcdf",
concat_dim="time",
combine="nested",
storage_options={"skip_instance_cache": False},
)
assert_identical(xr.concat([ds1, ds2], dim="time"), ds)
) as ds:
assert_identical(xr.concat([ds1, ds2], dim="time"), ds)
1 change: 1 addition & 0 deletions xarray/tests/test_computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ def test_apply_groupby_add() -> None:
add(data_array.groupby("y"), data_array.groupby("x"))


@pytest.mark.filterwarnings("ignore:Duplicate dimension names present")
def test_unified_dim_sizes() -> None:
assert unified_dim_sizes([xr.Variable((), 0)]) == {}
assert unified_dim_sizes([xr.Variable("x", [1]), xr.Variable("x", [1])]) == {"x": 1}
Expand Down
2 changes: 2 additions & 0 deletions xarray/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6007,6 +6007,8 @@ def test_dataset_number_math(self) -> None:
actual += 0
assert_identical(ds, actual)

# casting nan warns
@pytest.mark.filterwarnings("ignore:invalid value encountered in cast")
def test_unary_ops(self) -> None:
ds = self.make_example_math_dataset()

Expand Down
3 changes: 2 additions & 1 deletion xarray/tests/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -2952,7 +2952,8 @@ def test_from_sparse(self, Var):
import sparse

arr = np.diagflat([1, 2, 3])
sparr = sparse.COO(coords=[[0, 1, 2], [0, 1, 2]], data=[1, 2, 3])
coords = np.array([[0, 1, 2], [0, 1, 2]])
sparr = sparse.COO(coords=coords, data=[1, 2, 3], shape=(3, 3))
v = Variable(["x", "y"], sparr)

assert_identical(v.as_numpy(), Variable(["x", "y"], arr))
Expand Down
Loading