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

Method substitute

dask/_task_spec.py:952–969  ·  view source on GitHub ↗
(
        self, subs: dict[KeyType, KeyType | GraphNode], key: KeyType | None = None
    )

Source from the content-addressed store, hash-verified

950 return f"Dict({values})"
951
952 def substitute(
953 self, subs: dict[KeyType, KeyType | GraphNode], key: KeyType | None = None
954 ) -> Dict:
955 subs_filtered = {
956 k: v for k, v in subs.items() if k in self.dependencies and k != v
957 }
958 if not subs_filtered:
959 return self
960
961 new_args = []
962 for arg in self.args:
963 new_arg = (
964 arg.substitute(subs_filtered)
965 if isinstance(arg, (GraphNode, TaskRef))
966 else arg
967 )
968 new_args.append(new_arg)
969 return type(self)(new_args)
970
971 def __iter__(self):
972 yield from self.args[::2]

Callers

nothing calls this directly

Calls 2

itemsMethod · 0.45
substituteMethod · 0.45

Tested by

no test coverage detected