MCPcopy
hub / github.com/pydata/xarray / test_minimize_graph_size

Function test_minimize_graph_size

xarray/tests/test_dask.py:1832–1854  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1830
1831
1832def test_minimize_graph_size():
1833 # regression test for https://github.com/pydata/xarray/issues/8409
1834 ds = Dataset(
1835 {
1836 "foo": (
1837 ("x", "y", "z"),
1838 dask.array.ones((120, 120, 120), chunks=(20, 20, 1)),
1839 )
1840 },
1841 coords={"x": np.arange(120), "y": np.arange(120), "z": np.arange(120)},
1842 )
1843
1844 mapped = ds.map_blocks(lambda x: x)
1845 graph = dict(mapped.__dask_graph__())
1846
1847 numchunks = {k: len(v) for k, v in ds.chunksizes.items()}
1848 for var in "xyz":
1849 actual = len([key for key in graph if var in key[0]])
1850 # assert that we only include each chunk of an index variable
1851 # is only included once, not the product of number of chunks of
1852 # all the other dimensions.
1853 # e.g. previously for 'x', actual == numchunks['y'] * numchunks['z']
1854 assert actual == numchunks[var], (actual, numchunks[var])
1855
1856
1857def test_idxmin_chunking():

Callers

nothing calls this directly

Calls 5

map_blocksMethod · 0.95
DatasetClass · 0.90
arangeMethod · 0.80
itemsMethod · 0.80
__dask_graph__Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…