()
| 24 | |
| 25 | |
| 26 | def 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 | |
| 59 | def test_fmin_fn(): |
nothing calls this directly
no test coverage detected