MCPcopy
hub / github.com/hyperopt/hyperopt / test_arbitrary_ids

Method test_arbitrary_ids

hyperopt/tests/test_base.py:101–117  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

99 return idxs, vals
100
101 def test_arbitrary_ids(self):
102 # -- suggest implementations should work for arbitrary ID
103 # values (possibly assuming they are hashable), and the
104 # ID values should have no effect on the return values.
105 ids_1 = [-2, 0, 7, "a", "007", 66, "a3", "899", 23, 2333]
106 ids_2 = ["a", "b", "c", "d", 1, 2, 3, 0.1, 0.2, 0.3]
107 idxs_1, vals_1 = self.idxs_vals_from_ids(ids=ids_1, seed=45)
108 idxs_2, vals_2 = self.idxs_vals_from_ids(ids=ids_2, seed=45)
109 all_ids_1 = set()
110 for var, ids in list(idxs_1.items()):
111 all_ids_1.update(ids)
112 all_ids_2 = set()
113 for var, ids in list(idxs_2.items()):
114 all_ids_2.update(ids)
115 self.assertEqual(all_ids_1, set(ids_1))
116 self.assertEqual(all_ids_2, set(ids_2))
117 self.assertEqual(vals_1, vals_2)
118
119 def test_seed_randomizes(self):
120 #

Callers

nothing calls this directly

Calls 3

idxs_vals_from_idsMethod · 0.95
itemsMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected