def test_bad_register(self, hyperband: Hyperband, bracket: HyperbandBracket): """Check that a non-valid point is not registered.""" assert bracket.owner is hyperband with pytest.raises(IndexError) as ex: bracket.register(create_trial_for_hb((55, 0.0), 0.0)) assert "Bad fidelity level 55" in str(ex.value)
def test_register(self, hyperband: Hyperband, bracket: HyperbandBracket): """Check that a point is correctly registered inside a bracket.""" assert bracket.owner is hyperband trial = create_trial_for_hb((1, 0.0), 0.0) trial_id = hyperband.get_id(trial, ignore_fidelity=True) bracket.register(trial) assert len(bracket.rungs[0]) assert trial_id in bracket.rungs[0]["results"] assert trial.objective is not None assert bracket.rungs[0]["results"][trial_id][ 0] == trial.objective.value assert bracket.rungs[0]["results"][trial_id][1].to_dict( ) == trial.to_dict()