MCPcopy
hub / github.com/hyperopt/hyperopt / dfs

Function dfs

hyperopt/pyll/base.py:672–689  ·  view source on GitHub ↗
(aa, seq=None, seqset=None)

Source from the content-addressed store, hash-verified

670
671
672def dfs(aa, seq=None, seqset=None):
673 if seq is None:
674 assert seqset is None
675 seq = []
676 seqset = {}
677 # -- seqset is the set of all nodes we have seen (which may be still on
678 # the stack)
679 # N.B. it used to be a stack, but now it's a dict mapping to inputs
680 # because that's an optimization saving us from having to call inputs
681 # so often.
682 if aa in seqset:
683 return
684 assert isinstance(aa, Apply)
685 seqset[aa] = aa.inputs()
686 for ii in seqset[aa]:
687 dfs(ii, seq, seqset)
688 seq.append(aa)
689 return seq
690
691
692def toposort(expr):

Callers 12

test_dfsFunction · 0.90
test_clone_mergeFunction · 0.90
test_cloneFunction · 0.90
__init__Method · 0.85
toposortFunction · 0.85
cloneFunction · 0.85
clone_mergeFunction · 0.85
rec_evalFunction · 0.85
recursive_set_rng_kwargFunction · 0.85

Calls 1

inputsMethod · 0.80

Tested by 4

test_dfsFunction · 0.72
test_clone_mergeFunction · 0.72
test_cloneFunction · 0.72