def test_no_promotion_if_not_completed(self, hyperband: Hyperband, bracket: HyperbandBracket, rung_0: RungDict): """Test the get_candidate return None if trials are not completed.""" assert bracket.owner is hyperband bracket.rungs[0] = rung_0 rung = bracket.rungs[0]["results"] # points = bracket.get_candidates(0) for p_id in rung.keys(): rung[p_id] = (None, rung[p_id][1]) with pytest.raises(TypeError): bracket.get_candidates(0)
def test_candidate_promotion(self, hyperband: Hyperband, bracket: HyperbandBracket, rung_0: RungDict): """Test that correct point is promoted.""" assert bracket.owner is hyperband bracket.rungs[0] = rung_0 points = bracket.get_candidates(0) assert points[0].params == create_trial_for_hb((1, 0.0), 0.0).params
def test_no_promotion_when_rung_full( self, hyperband: Hyperband, bracket: HyperbandBracket, rung_0: RungDict, rung_1: RungDict, ): """Test that get_candidate returns `None` if rung 1 is full.""" assert bracket.owner is hyperband bracket.rungs[0] = rung_0 bracket.rungs[1] = rung_1 points = bracket.get_candidates(0) assert points == []
def test_promotion_with_rung_1_hit(self, hyperband: Hyperband, bracket: HyperbandBracket, rung_0: RungDict): """Test that get_candidate gives us the next best thing if point is already in rung 1.""" trial = create_trial_for_hb((1, 0.0), None) assert bracket.owner is hyperband bracket.rungs[0] = rung_0 assert trial.objective is not None bracket.rungs[1]["results"][hyperband.get_id(trial, ignore_fidelity=True)] = ( trial.objective.value, trial, ) trials = bracket.get_candidates(0) assert trials[0].params == create_trial_for_hb((1, 1), 0.0).params