MCPcopy Create free account
hub / github.com/dask/dask / test_graph_from_arraylike

Function test_graph_from_arraylike

dask/array/tests/test_array_core.py:107–128  ·  view source on GitHub ↗
(inline_array)

Source from the content-addressed store, hash-verified

105
106@pytest.mark.parametrize("inline_array", [True, False])
107def test_graph_from_arraylike(inline_array):
108 d = 2
109 chunk = (2, 3)
110 shape = tuple(d * n for n in chunk)
111 arr = np.ones(shape)
112
113 dsk = graph_from_arraylike(
114 arr, chunk, shape=shape, name="X", inline_array=inline_array
115 )
116
117 assert isinstance(dsk, HighLevelGraph)
118 if inline_array:
119 assert len(dsk.layers) == 1
120 assert isinstance(hlg_layer_topological(dsk, 0), Blockwise)
121 else:
122 assert len(dsk.layers) == 2
123 assert isinstance(hlg_layer_topological(dsk, 0), MaterializedLayer)
124 assert isinstance(hlg_layer_topological(dsk, 1), Blockwise)
125 dsk = dict(dsk)
126
127 # Somewhat odd membership check to avoid numpy elemwise __in__ overload
128 assert any(arr is v for v in dsk.values()) is not inline_array
129
130
131def test_top():

Callers

nothing calls this directly

Calls 5

graph_from_arraylikeFunction · 0.90
hlg_layer_topologicalFunction · 0.90
anyFunction · 0.85
onesMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected