MCPcopy Index your code
hub / github.com/pydata/xarray / test_inline_array

Method test_inline_array

xarray/tests/test_backends.py:6541–6562  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6539 reason="counting number of tasks in graph fails on windows for some reason",
6540 )
6541 def test_inline_array(self) -> None:
6542 with create_tmp_file() as tmp:
6543 original = Dataset({"foo": ("x", np.random.randn(10))})
6544 original.to_netcdf(tmp)
6545 chunks = {"time": 10}
6546
6547 def num_graph_nodes(obj):
6548 return len(obj.__dask_graph__())
6549
6550 with (
6551 open_dataset(tmp, inline_array=False, chunks=chunks) as not_inlined_ds,
6552 open_dataset(tmp, inline_array=True, chunks=chunks) as inlined_ds,
6553 ):
6554 assert num_graph_nodes(inlined_ds) < num_graph_nodes(not_inlined_ds)
6555
6556 with (
6557 open_dataarray(
6558 tmp, inline_array=False, chunks=chunks
6559 ) as not_inlined_da,
6560 open_dataarray(tmp, inline_array=True, chunks=chunks) as inlined_da,
6561 ):
6562 assert num_graph_nodes(inlined_da) < num_graph_nodes(not_inlined_da)
6563
6564
6565@requires_scipy_or_netCDF4

Callers

nothing calls this directly

Calls 5

to_netcdfMethod · 0.95
DatasetClass · 0.90
open_datasetFunction · 0.90
open_dataarrayFunction · 0.90
create_tmp_fileFunction · 0.85

Tested by

no test coverage detected