pg.hyper.trace

Accessible via pg.hyper.trace.

trace(fun, *, where=None, require_hyper_name=False, per_thread=True)[source]

Trace the hyper primitives called within a function by executing it.

See examples in pg.hyper.DynamicEvaluationContext.

Return type:

pg.hyper.DynamicEvaluationContext

Parameters:
  • fun – Function in which the search space is defined.

  • where – A callable object that decide whether a hyper primitive should be included when being instantiated under collect. If None, all hyper primitives under collect will be included.

  • require_hyper_name – If True, all hyper primitives defined in this scope will need to carry their names, which is usually a good idea when the function that instantiates the hyper primtives need to be called multiple times.

  • per_thread – If True, the context manager will be applied to current thread only. Otherwise, it will be applied on current process.

Returns:

An DynamicEvaluationContext that can be passed to pg.sample.