MCPcopy
hub / github.com/hyperopt/hyperopt / evaluate_async2

Method evaluate_async2

hyperopt/base.py:941–968  ·  view source on GitHub ↗

this is the second part of async evaluation for ipython parallel engines (see ipy.py)

(self, rval, ctrl, attach_attachments=True)

Source from the content-addressed store, hash-verified

939 return (self.fn, pyll_rval)
940
941 def evaluate_async2(self, rval, ctrl, attach_attachments=True):
942 """
943 this is the second part of async evaluation for ipython parallel engines (see ipy.py)
944 """
945 if isinstance(rval, (float, int, np.number)):
946 dict_rval = {"loss": float(rval), "status": STATUS_OK}
947 else:
948 dict_rval = dict(rval)
949 status = dict_rval["status"]
950 if status not in STATUS_STRINGS:
951 raise InvalidResultStatus(dict_rval)
952
953 if status == STATUS_OK:
954 # -- make sure that the loss is present and valid
955 try:
956 dict_rval["loss"] = float(dict_rval["loss"])
957 except (TypeError, KeyError):
958 raise InvalidLoss(dict_rval)
959
960 if attach_attachments:
961 attachments = dict_rval.pop("attachments", {})
962 for key, val in list(attachments.items()):
963 ctrl.attachments[key] = val
964
965 # -- don't do this here because SON-compatibility is only a requirement
966 # for trials destined for a mongodb. In-memory rvals can contain
967 # anything.
968 return dict_rval
969
970 def short_str(self):
971 return "Domain{%s}" % str(self.fn)

Callers 1

getMethod · 0.80

Calls 3

InvalidResultStatusClass · 0.85
InvalidLossClass · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected