Skip to content

Commit

Permalink
Add first tests but the fail :')
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamc committed Jun 30, 2022
1 parent ea73cc0 commit 12afcaf
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/test_CARLEnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,39 @@ def test_context_feature_scaling_unknown_step(self):
with self.assertRaises(ValueError):
next_obs, reward, done, info = env.step(action=action)

def test_context_mask(self):
context_mask = ["dt", "g"]
env = ( # noqa: F841 local variable is assigned to but never used
CARLPendulumEnv(
contexts={},
hide_context=False,
context_mask=context_mask,
dict_observation_space=True,
add_gaussian_noise_to_context=False,
gaussian_noise_std_percentage=0.01,
state_context_features=None,
scale_context_features="no",
)
)
s = env.reset()
s_c = s["context"]
forbidden_in_context = [f for f in env.state_context_features if f in context_mask]
self.assertTrue(len(s_c) == len(list(env.default_context.keys())) - 2)
self.assertTrue(len(forbidden_in_context) == 0)

def test_state_context_feature_population(self):
env = ( # noqa: F841 local variable is assigned to but never used
CARLPendulumEnv(
contexts={},
hide_context=False,
add_gaussian_noise_to_context=False,
gaussian_noise_std_percentage=0.01,
state_context_features=None,
scale_context_features="no",
)
)
self.assertIsNotNone(env.state_context_features)


class TestContextSelection(unittest.TestCase):
@staticmethod
Expand Down

0 comments on commit 12afcaf

Please sign in to comment.