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 a bunch of CachingFileManager warnings #8584

Merged
merged 2 commits into from
Jan 3, 2024
Merged
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
30 changes: 18 additions & 12 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2232,10 +2232,10 @@ def test_chunk_encoding_with_dask(self) -> None:
pass

def test_drop_encoding(self):
ds = open_example_dataset("example_1.nc")
encodings = {v: {**ds[v].encoding} for v in ds.data_vars}
with self.create_zarr_target() as store:
ds.to_zarr(store, encoding=encodings)
with open_example_dataset("example_1.nc") as ds:
encodings = {v: {**ds[v].encoding} for v in ds.data_vars}
with self.create_zarr_target() as store:
ds.to_zarr(store, encoding=encodings)

def test_hidden_zarr_keys(self) -> None:
expected = create_test_data()
Expand Down Expand Up @@ -4417,13 +4417,19 @@ def test_inline_array(self) -> None:
def num_graph_nodes(obj):
return len(obj.__dask_graph__())

not_inlined_ds = open_dataset(tmp, inline_array=False, chunks=chunks)
inlined_ds = open_dataset(tmp, inline_array=True, chunks=chunks)
assert num_graph_nodes(inlined_ds) < num_graph_nodes(not_inlined_ds)
with open_dataset(
tmp, inline_array=False, chunks=chunks
) as not_inlined_ds, open_dataset(
tmp, inline_array=True, chunks=chunks
) as inlined_ds:
assert num_graph_nodes(inlined_ds) < num_graph_nodes(not_inlined_ds)

not_inlined_da = open_dataarray(tmp, inline_array=False, chunks=chunks)
inlined_da = open_dataarray(tmp, inline_array=True, chunks=chunks)
assert num_graph_nodes(inlined_da) < num_graph_nodes(not_inlined_da)
with open_dataarray(
tmp, inline_array=False, chunks=chunks
) as not_inlined_da, open_dataarray(
tmp, inline_array=True, chunks=chunks
) as inlined_da:
assert num_graph_nodes(inlined_da) < num_graph_nodes(not_inlined_da)


@requires_scipy_or_netCDF4
Expand Down Expand Up @@ -5335,8 +5341,8 @@ def test_raise_writing_to_nczarr(self, mode) -> None:
@requires_netCDF4
@requires_dask
def test_pickle_open_mfdataset_dataset():
ds = open_example_mfdataset(["bears.nc"])
assert_identical(ds, pickle.loads(pickle.dumps(ds)))
with open_example_mfdataset(["bears.nc"]) as ds:
assert_identical(ds, pickle.loads(pickle.dumps(ds)))


@requires_zarr
Expand Down
Loading