Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsilver committed Dec 5, 2023
1 parent af72766 commit b25d08b
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions tests/test_competence_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,25 @@ def test_legacy_skill_competence_model():
"""Tests for LegacySkillCompetenceModel()."""
utils.reset_config({
"skill_competence_default_alpha_beta": (1.0, 1.0),
"skill_competence_initial_prediction_bonus": 1e-2,
})
model = create_competence_model("legacy", "test")
assert isinstance(model, LegacySkillCompetenceModel)
assert np.isclose(model.get_current_competence(), 0.5)
assert np.isclose(model.predict_competence(1), 0.5 + 1e-2)
assert np.isclose(model.predict_competence(1),
0.5 + CFG.skill_competence_initial_prediction_bonus)
model.observe(True)
assert model.get_current_competence() > 0.5
assert model.predict_competence(1) > 0.5 + 1e-2
assert model.predict_competence(
1) > 0.5 + CFG.skill_competence_initial_prediction_bonus
model.observe(False)
assert np.isclose(model.get_current_competence(), 0.5)
assert np.isclose(model.predict_competence(1), 0.5 + 1e-2)
assert np.isclose(model.predict_competence(1),
0.5 + CFG.skill_competence_initial_prediction_bonus)
model.advance_cycle()
assert np.isclose(model.get_current_competence(), 0.5)
assert np.isclose(model.predict_competence(1), 0.5 + 1e-2)
assert np.isclose(model.predict_competence(1),
0.5 + CFG.skill_competence_initial_prediction_bonus)
model.observe(True)
assert model.get_current_competence() > 0.5

Expand All @@ -53,10 +58,12 @@ def test_latent_variable_skill_competence_model_short():
"skill_competence_model_num_em_iters": 1,
"skill_competence_model_max_train_iters": 10,
"skill_competence_default_alpha_beta": (1.0, 1.0),
"skill_competence_initial_prediction_bonus": 1e-2,
})
model = create_competence_model("latent_variable", "test")
assert np.isclose(model.get_current_competence(), 0.5)
assert np.isclose(model.predict_competence(1), 0.5 + 1e-2)
assert np.isclose(model.predict_competence(1),
0.5 + CFG.skill_competence_initial_prediction_bonus)
model.observe(True)
assert model.get_current_competence() > 0.5
assert model.predict_competence(1) > model.get_current_competence()
Expand All @@ -72,12 +79,14 @@ def test_optimistic_skill_competence_model():
"""Tests for OptimisticSkillCompetenceModel()."""
utils.reset_config({
"skill_competence_default_alpha_beta": (1.0, 1.0),
"skill_competence_initial_prediction_bonus": 1e-2,
})
h = CFG.skill_competence_model_lookahead

model = create_competence_model("optimistic", "test")
assert np.isclose(model.get_current_competence(), 0.5)
assert np.isclose(model.predict_competence(h), 0.5 + 1e-2)
assert np.isclose(model.predict_competence(h),
0.5 + CFG.skill_competence_initial_prediction_bonus)

# Test impossible skill.
model = create_competence_model("optimistic", "impossible-skill")
Expand Down Expand Up @@ -154,12 +163,14 @@ def test_latent_variable_skill_competence_model_long():
"""Long tests for LatentVariableSkillCompetenceModel()."""
utils.reset_config({
"skill_competence_default_alpha_beta": (1.0, 1.0),
"skill_competence_initial_prediction_bonus": 1e-2,
})
h = CFG.skill_competence_model_lookahead

model = create_competence_model("latent_variable", "test")
assert np.isclose(model.get_current_competence(), 0.5)
assert np.isclose(model.predict_competence(h), 0.5 + 1e-2)
assert np.isclose(model.predict_competence(h),
0.5 + CFG.skill_competence_initial_prediction_bonus)

# Test impossible skill.
model = create_competence_model("latent_variable", "impossible-skill")
Expand Down

0 comments on commit b25d08b

Please sign in to comment.