MCPcopy
hub / github.com/hyperopt/hyperopt / eval

Method eval

hyperopt/pyll/base.py:255–284  ·  view source on GitHub ↗

Recursively evaluate an expression graph. This method operates directly on the graph of extended inputs to this node, making no attempt to modify or optimize the expression graph. Caveats: * If there are nodes in the graph that do not represent expressio

(self, memo=None)

Source from the content-addressed store, hash-verified

253 scope.define_if_new(**self.define_params)
254
255 def eval(self, memo=None):
256 """
257 Recursively evaluate an expression graph.
258
259 This method operates directly on the graph of extended inputs to this
260 node, making no attempt to modify or optimize the expression graph.
261
262 Caveats:
263
264 * If there are nodes in the graph that do not represent expressions,
265 (e.g. nodes that correspond to statement blocks or assertions)
266 then it's not clear what this routine should do, and you should
267 probably not call it.
268
269 * If there are Lambdas in the graph, this procedure will not evluate
270 them -- see rec_eval for that.
271
272 However, for many cases that are pure expression graphs, this
273 offers a quick and simple way to evaluate them.
274 """
275 if memo is None:
276 memo = {}
277 if id(self) in memo:
278 return memo[id(self)]
279 else:
280 args = [a.eval() for a in self.pos_args]
281 kwargs = {n: a.eval() for (n, a) in self.named_args}
282 f = scope._impls[self.name]
283 memo[id(self)] = rval = f(*args, **kwargs)
284 return rval
285
286 def inputs(self):
287 # -- this function gets called a lot and it's not 100% safe to cache

Callers 5

space_evalFunction · 0.45
test_eval_arithmeticFunction · 0.45
test_clone_mergeFunction · 0.45
test_expr_to_configFunction · 0.45

Calls

no outgoing calls

Tested by 4

test_eval_arithmeticFunction · 0.36
test_clone_mergeFunction · 0.36
test_expr_to_configFunction · 0.36