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

Function _process_match

dask/rewrite.py:412–437  ·  view source on GitHub ↗

Process a match to determine if it is correct, and to find the correct substitution that will convert the term into the pattern. Parameters ---------- rule : RewriteRule syms : iterable Iterable of subterms that match a corresponding variable. Returns -------

(rule, syms)

Source from the content-addressed store, hash-verified

410
411
412def _process_match(rule, syms):
413 """Process a match to determine if it is correct, and to find the correct
414 substitution that will convert the term into the pattern.
415
416 Parameters
417 ----------
418 rule : RewriteRule
419 syms : iterable
420 Iterable of subterms that match a corresponding variable.
421
422 Returns
423 -------
424 A dictionary of {vars : subterms} describing the substitution to make the
425 pattern equivalent with the term. Returns `None` if the match is
426 invalid."""
427
428 subs = {}
429 varlist = rule._varlist
430 if not len(varlist) == len(syms):
431 raise RuntimeError("length of varlist doesn't match length of syms.")
432 for v, s in zip(varlist, syms):
433 if v in subs and subs[v] != s:
434 return None
435 else:
436 subs[v] = s
437 return subs

Callers 1

iter_matchesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected