Skip to content

Commit

Permalink
Revert test carl env
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamc committed Aug 8, 2023
1 parent 252494d commit b579db8
Showing 1 changed file with 0 additions and 84 deletions.
84 changes: 0 additions & 84 deletions test/test_CARLEnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,90 +26,6 @@ def test_observation_reducedcontext(self):
env = CARLPendulum(obs_context_features=context_keys)
state, info = env.reset()
self.assertEqual(len(state["context"]), n)


def test_get_context_key(self):
contexts = self.generate_contexts()
env = CARLPendulumEnv(contexts=contexts)
self.assertEqual(env.context_key, None)


class TestContextSampler(unittest.TestCase):
def test_get_defaults(self):
from carl.context.sampling import get_default_context_and_bounds

defaults, bounds = get_default_context_and_bounds(env_name="CARLPendulumEnv")
DEFAULT_CONTEXT = {
"max_speed": 8.0,
"dt": 0.05,
"g": 10.0,
"m": 1.0,
"l": 1.0,
"initial_angle_max": np.pi,
"initial_velocity_max": 1,
}
self.assertDictEqual(defaults, DEFAULT_CONTEXT)

def test_sample_contexts(self):
from carl.context.sampling import sample_contexts

contexts = sample_contexts(
env_name="CARLPendulumEnv",
context_feature_args=["l"],
num_contexts=1,
default_sample_std_percentage=0.0,
)
self.assertEqual(contexts[0]["l"], 1)


class TestContextAugmentation(unittest.TestCase):
def test_gaussian_noise(self):
from carl.context.augmentation import add_gaussian_noise

c = add_gaussian_noise(default_value=1, percentage_std=0)
self.assertEqual(c, 1)

def test_get_context_key(self):
contexts = self.generate_contexts()
env = CARLPendulumEnv(contexts=contexts)
self.assertEqual(env.context_key, None)


class TestContextSampler(unittest.TestCase):
def test_get_defaults(self):
from carl.context.sampling import get_default_context_and_bounds

defaults, bounds = get_default_context_and_bounds(env_name="CARLPendulumEnv")
DEFAULT_CONTEXT = {
"max_speed": 8.0,
"dt": 0.05,
"g": 10.0,
"m": 1.0,
"l": 1.0,
"initial_angle_max": np.pi,
"initial_velocity_max": 1,
}
self.assertDictEqual(defaults, DEFAULT_CONTEXT)

def test_sample_contexts(self):
from carl.context.sampling import sample_contexts

contexts = sample_contexts(
env_name="CARLPendulumEnv",
context_feature_args=["l"],
num_contexts=1,
default_sample_std_percentage=0.0,
)
self.assertEqual(contexts[0]["l"], 1)


class TestContextAugmentation(unittest.TestCase):
def test_gaussian_noise(self):
from carl.context.augmentation import add_gaussian_noise

c = add_gaussian_noise(default_value=1, percentage_std=0)
self.assertEqual(c, 1)



if __name__ == "__main__":
Expand Down

0 comments on commit b579db8

Please sign in to comment.