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

Method __dask_annotations__

dask/_expr.py:1171–1193  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1169 _layer = __dask_graph__
1170
1171 def __dask_annotations__(self) -> dict[str, dict[Key, object]]:
1172 # optimization has to be called (and cached) since blockwise fusion can
1173 # alter annotations
1174 # see `dask.blockwise.(_fuse_annotations|_can_fuse_annotations)`
1175 dsk = self._optimized_dsk
1176 annotations_by_type: defaultdict[str, dict[Key, object]] = defaultdict(dict)
1177 for layer in dsk.layers.values():
1178 if layer.annotations:
1179 annot = layer.annotations
1180 for annot_type, value in annot.items():
1181 annots = list(
1182 (k, (value(k) if callable(value) else value)) for k in layer
1183 )
1184 annotations_by_type[annot_type].update(
1185 {
1186 k: v
1187 for k, v in annots
1188 if not isinstance(v, _AnnotationsTombstone)
1189 }
1190 )
1191 if not annotations_by_type[annot_type]:
1192 del annotations_by_type[annot_type]
1193 return dict(annotations_by_type)
1194
1195 def __dask_keys__(self) -> list:
1196 all_keys = []

Callers

nothing calls this directly

Calls 2

valuesMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected