MCPcopy
hub / github.com/hyperopt/hyperopt / test0

Function test0

hyperopt/tests/unit/test_ipy.py:26–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24
25
26def test0():
27 try:
28 client = Client(debug=True)
29 except OSError:
30 raise SkipTest()
31
32 client[:].use_cloudpickle()
33 trials = IPythonTrials(client, "log")
34
35 def simple_objective(args):
36 # -- why are these imports here !?
37 # -- is it because they need to be imported on the client?
38 #
39 # Yes, the client namespace is empty, so some imports may be
40 # needed here. Errors on the engines can be found by
41 # using debug=True when instantiating the Client.
42 import hyperopt
43
44 return {"loss": args ** 2, "status": hyperopt.STATUS_OK}
45
46 space = hyperopt.hp.uniform("x", 0, 1)
47
48 minval = trials.fmin(
49 simple_objective,
50 space=space,
51 algo=hyperopt.tpe.suggest,
52 max_evals=25,
53 verbose=True,
54 )
55 print(minval)
56 assert minval["x"] < 0.2
57
58
59def test_fmin_fn():

Callers

nothing calls this directly

Calls 2

fminMethod · 0.95
IPythonTrialsClass · 0.90

Tested by

no test coverage detected