MCPcopy
hub / github.com/hyperopt/hyperopt / miscs_update_idxs_vals

Function miscs_update_idxs_vals

hyperopt/base.py:163–188  ·  view source on GitHub ↗

Unpack the idxs-vals format into the list of dictionaries that is `misc`. idxs_map: a dictionary of id->id mappings so that the misc['idxs'] can contain different numbers than the idxs argument. XXX CLARIFY

(miscs, idxs, vals, assert_all_vals_used=True, idxs_map=None)

Source from the content-addressed store, hash-verified

161
162
163def miscs_update_idxs_vals(miscs, idxs, vals, assert_all_vals_used=True, idxs_map=None):
164 """
165 Unpack the idxs-vals format into the list of dictionaries that is `misc`.
166
167 idxs_map: a dictionary of id->id mappings so that the misc['idxs'] can
168 contain different numbers than the idxs argument. XXX CLARIFY
169 """
170 if idxs_map is None:
171 idxs_map = {}
172
173 assert set(idxs.keys()) == set(vals.keys())
174
175 misc_by_id = {m["tid"]: m for m in miscs}
176 for m in miscs:
177 m["idxs"] = {key: [] for key in idxs}
178 m["vals"] = {key: [] for key in idxs}
179
180 for key in idxs:
181 assert len(idxs[key]) == len(vals[key])
182 for tid, val in zip(idxs[key], vals[key]):
183 tid = idxs_map.get(tid, tid)
184 if assert_all_vals_used or tid in misc_by_id:
185 misc_by_id[tid]["idxs"][key] = [tid]
186 misc_by_id[tid]["vals"][key] = [val]
187
188 return miscs
189
190
191def miscs_to_idxs_vals(miscs, keys=None):

Callers 3

suggestFunction · 0.85
__call__Method · 0.85
suggestFunction · 0.85

Calls 2

keysMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected