MCPcopy
hub / github.com/hyperopt/hyperopt / test_vectorize_simple

Function test_vectorize_simple

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

Source from the content-addressed store, hash-verified

69
70
71def test_vectorize_simple():
72 N = as_apply(15)
73
74 p0 = hp_uniform("p0", 0, 1)
75 loss = p0 ** 2
76 print(loss)
77 expr_idxs = scope.range(N)
78 vh = VectorizeHelper(loss, expr_idxs, build=True)
79 vloss = vh.v_expr
80
81 full_output = as_apply([vloss, vh.idxs_by_label(), vh.vals_by_label()])
82 fo2 = replace_repeat_stochastic(full_output)
83
84 new_vc = recursive_set_rng_kwarg(fo2, as_apply(np.random.default_rng(1)))
85
86 # print new_vc
87 losses, idxs, vals = rec_eval(new_vc)
88 print("losses", losses)
89 print("idxs p0", idxs["p0"])
90 print("vals p0", vals["p0"])
91 p0dct = dict(list(zip(idxs["p0"], vals["p0"])))
92 for ii, li in enumerate(losses):
93 assert p0dct[ii] ** 2 == li
94
95
96def test_vectorize_multipath():

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