MCPcopy Index your code
hub / github.com/dask/dask / _check_dsk

Function _check_dsk

dask/array/utils.py:205–229  ·  view source on GitHub ↗

Check that graph is well named and non-overlapping

(dsk)

Source from the content-addressed store, hash-verified

203
204
205def _check_dsk(dsk):
206 """Check that graph is well named and non-overlapping"""
207 if not isinstance(dsk, HighLevelGraph):
208 return
209
210 dsk.validate()
211 assert all(isinstance(k, (tuple, str)) for k in dsk.layers)
212 freqs = frequencies(concat(dsk.layers.values()))
213 non_one = {k: v for k, v in freqs.items() if v != 1}
214 key_collisions = set()
215 # Allow redundant keys if the values are equivalent
216 collisions = set()
217 all_keys = set(dsk)
218 layers = [convert_legacy_graph(layer, all_keys) for layer in dsk.layers.values()]
219 for k in non_one.keys():
220 for layer in layers:
221 try:
222 key_collisions.add(tokenize(layer[k]))
223 except KeyError:
224 pass
225 if len(key_collisions) >= 2:
226 collisions.add(k)
227 key_collisions.clear()
228
229 assert len(collisions) == 0, {k: non_one[k] for k in collisions}
230
231
232def assert_eq_shape(a, b, check_ndim=True, check_nan=True):

Callers 2

test_keys_from_arrayFunction · 0.90
_get_dt_meta_computedFunction · 0.85

Calls 11

convert_legacy_graphFunction · 0.90
allFunction · 0.85
setClass · 0.85
validateMethod · 0.80
concatFunction · 0.50
tokenizeFunction · 0.50
valuesMethod · 0.45
itemsMethod · 0.45
keysMethod · 0.45
addMethod · 0.45
clearMethod · 0.45

Tested by 1

test_keys_from_arrayFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…