Skip to content

Commit

Permalink
Silence a bunch of CachingFileManager warnings (#8584)
Browse files Browse the repository at this point in the history
* Silence a bunch of CachingFileManager warnings

* Silence more.
  • Loading branch information
dcherian authored Jan 3, 2024
1 parent 1ebd3dd commit 92f79a0
Showing 1 changed file with 18 additions and 12 deletions.
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

0 comments on commit 92f79a0

Please sign in to comment.