MCPcopy
hub / github.com/hyperopt/hyperopt / sample

Function sample

hyperopt/pyll/stochastic.py:193–208  ·  view source on GitHub ↗

Parameters: expr - a pyll expression to be evaluated rng - a np.random.Generator instance default: `np.random.default_rng()` **kwargs - optional arguments passed along to `hyperopt.pyll.rec_eval`

(expr, rng=None, **kwargs)

Source from the content-addressed store, hash-verified

191
192
193def sample(expr, rng=None, **kwargs):
194 """
195 Parameters:
196 expr - a pyll expression to be evaluated
197
198 rng - a np.random.Generator instance
199 default: `np.random.default_rng()`
200
201 **kwargs - optional arguments passed along to
202 `hyperopt.pyll.rec_eval`
203
204 """
205 if rng is None:
206 rng = np.random.default_rng()
207 foo = recursive_set_rng_kwarg(clone(as_apply(expr)), as_apply(rng))
208 return rec_eval(foo, **kwargs)

Callers 4

test_repeatableFunction · 0.90
test_sampleFunction · 0.90

Calls 4

recursive_set_rng_kwargFunction · 0.85
cloneFunction · 0.85
as_applyFunction · 0.85
rec_evalFunction · 0.85

Tested by 4

test_repeatableFunction · 0.72
test_sampleFunction · 0.72