MCPcopy
hub / github.com/dask/dask / test_creation_data_producers

Function test_creation_data_producers

dask/array/tests/test_creation.py:567–592  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

565
566
567def test_creation_data_producers():
568 x = np.arange(64).reshape((8, 8))
569 d = da.from_array(x, chunks=(4, 4))
570 dsk = collections_to_expr([d]).__dask_graph__()
571 assert all(v.data_producer for v in dsk.values())
572
573 # blockwise fusion
574 x = d.astype("float64")
575 dsk = collections_to_expr([x]).__dask_graph__()
576 assert sum(v.data_producer for v in dsk.values()) == 4
577 assert sum(isinstance(v, Alias) for v in dsk.values()) == 4
578 assert len(dsk) == 8
579
580 # linear fusion
581 x = d[slice(0, 6), None].astype("float64")
582 dsk = collections_to_expr([x]).__dask_graph__()
583 assert sum(v.data_producer for v in dsk.values()) == 4
584 assert sum(isinstance(v, Alias) for v in dsk.values()) == 4
585 assert len(dsk) == 8
586
587 # no fusion
588 x = d[[1, 3, 5, 7, 6, 4, 2, 0]].astype("float64")
589 dsk = collections_to_expr([x]).__dask_graph__()
590 assert sum(v.data_producer and "array-" in k[0] for k, v in dsk.items()) == 4
591 assert sum(v.data_producer for v in dsk.values()) == 8 # getitem data nodes
592 assert len(dsk) == 24
593
594
595def test_diagonal():

Callers

nothing calls this directly

Calls 9

collections_to_exprFunction · 0.90
allFunction · 0.85
reshapeMethod · 0.80
sumFunction · 0.50
arangeMethod · 0.45
__dask_graph__Method · 0.45
valuesMethod · 0.45
astypeMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…