def __init__( self, start, stop, num, geomf, weightf, broadening, eindexf="full", aindexf="full", flatten=True, elems=None, acc=0.01, norm={"none": {}}, context={}, ): super().__init__(context=context) # TODO: insert argument checking here. self.mbtr_config = { "start": float(start), "stop": float(stop), "num": int(num), "geomf": geomf, "weightf": weightf, "broadening": float(broadening), "eindexf": eindexf, "aindexf": aindexf, "flatten": flatten, "elems": elems, "acc": float(acc), } self.norm = _from_config(norm, classes=norms)
def __init__( self, search, evaluator, stop, trial_timeout=None, caught_exceptions=["TimeoutError"], name=None, context={}, ): super().__init__(context=context) self.search = from_config(search) self.evaluator_config = to_config(evaluator) self.stop = _from_config(stop, classes=stoppers) self.trial_timeout = trial_timeout self.caught_exceptions = get_exceptions(caught_exceptions) self.id = compute_hash(time.time(), np.random.random(10)) # unique id of this run if name is None: self.name = humanize(self.id, words=2) else: self.name = name self.ready = False # run is not ready until prepared self.readonly = False # only True if instance is obtained through Run.checkout()
def test_it_works(self): config = {"hello": {"a": 2}} my = _from_config(config, classes=registry) self.assertEqual(my.a, 2) self.assertEqual(to_config(my), config)
def test_raises_valueerror_if_unknown(self): config = {"darkness": {"a": 2}} with self.assertRaises(ValueError): my = _from_config(config, classes=registry)
def get_kernelf(config, context={}): """Get a kernel function.""" return _from_config(config, classes=classes, context=context)