MCPcopy
hub / github.com/hyperopt/hyperopt / test_vectorize_trivial

Function test_vectorize_trivial

hyperopt/tests/unit/test_vectorize.py:46–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44
45
46def test_vectorize_trivial():
47 N = as_apply(15)
48
49 p0 = hp_uniform("p0", 0, 1)
50 loss = p0
51 print(loss)
52 expr_idxs = scope.range(N)
53 vh = VectorizeHelper(loss, expr_idxs, build=True)
54 vloss = vh.v_expr
55
56 full_output = as_apply([vloss, vh.idxs_by_label(), vh.vals_by_label()])
57 fo2 = replace_repeat_stochastic(full_output)
58
59 new_vc = recursive_set_rng_kwarg(fo2, as_apply(np.random.default_rng(1)))
60
61 # print new_vc
62 losses, idxs, vals = rec_eval(new_vc)
63 print("losses", losses)
64 print("idxs p0", idxs["p0"])
65 print("vals p0", vals["p0"])
66 p0dct = dict(list(zip(idxs["p0"], vals["p0"])))
67 for ii, li in enumerate(losses):
68 assert p0dct[ii] == li
69
70
71def test_vectorize_simple():

Callers

nothing calls this directly

Calls 9

idxs_by_labelMethod · 0.95
vals_by_labelMethod · 0.95
as_applyFunction · 0.90
hp_uniformFunction · 0.90
VectorizeHelperClass · 0.90
recursive_set_rng_kwargFunction · 0.90
rec_evalFunction · 0.90
rangeMethod · 0.80

Tested by

no test coverage detected