Skip to content

Commit

Permalink
fix pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEimer committed Dec 11, 2023
1 parent 4eca801 commit 897f373
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 39 deletions.
6 changes: 3 additions & 3 deletions carl/envs/gymnasium/carl_gymnasium_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

try:
pygame.display.init()
except: # pragma: no cover
import os # pragma: no cover
except: # pragma: no cover
import os # pragma: no cover

os.environ["SDL_VIDEODRIVER"] = "dummy" # pragma: no cover
os.environ["SDL_VIDEODRIVER"] = "dummy" # pragma: no cover


class CARLGymnasiumEnv(CARLEnv):
Expand Down
5 changes: 1 addition & 4 deletions test/test_context_sampler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import unittest
from omegaconf import DictConfig

from carl.context.context_space import (
ContextSpace,
Expand Down Expand Up @@ -47,7 +46,7 @@ def test_init(self):

with self.assertRaises(ValueError):
ContextSampler(
context_distributions=0,
context_distributions=0,
context_space=self.cspace,
seed=0,
name="TestSampler",
Expand All @@ -63,7 +62,5 @@ def test_sample_contexts(self):
self.assertEqual(contexts[0]["gravity"], 9.8)




if __name__ == "__main__":
unittest.main()
1 change: 1 addition & 0 deletions test/test_context_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@ def test_sample(self):
with self.assertRaises(ValueError):
self.context_space.sample_contexts(["false_feature"], size=0)


if __name__ == "__main__":
unittest.main()
62 changes: 30 additions & 32 deletions test/test_search_space_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,37 @@

from carl.context.search_space_encoding import search_space_to_config_space


dict_space = {
"uniform_integer": (1, 10),
"uniform_float": (1.0, 10.0),
"categorical": ["a", "b", "c"],
"constant": 1337,
}
"uniform_integer": (1, 10),
"uniform_float": (1.0, 10.0),
"categorical": ["a", "b", "c"],
"constant": 1337,
}

dict_space_2 = { "hyperparameters": [
{"name": "x0",
"type": "uniform_float",
"log": False,
"lower": -512.0,
"upper": 512.0,
"default": -3.0},
{"name": "x1",
"type": "uniform_float",
"log": False,
"lower": -512.0,
"upper": 512.0,
"default": -4.0}],
dict_space_2 = {
"hyperparameters": [
{
"name": "x0",
"type": "uniform_float",
"log": False,
"lower": -512.0,
"upper": 512.0,
"default": -3.0,
},
{
"name": "x1",
"type": "uniform_float",
"log": False,
"lower": -512.0,
"upper": 512.0,
"default": -4.0,
},
],
"conditions": [],
"forbiddens": [],
"python_module_version": "0.4.17",
"json_format_version": 0.2}
"json_format_version": 0.2,
}

str_space = """{
"uniform_integer": (1, 10),
Expand All @@ -38,25 +44,17 @@
"constant": 1337,
}"""


class TestSearchSpacEncoding(unittest.TestCase):
def setUp(self):
self.test_space = None
self.test_space = ConfigurationSpace(
name="myspace",
space=dict_space
)
self.test_space = ConfigurationSpace(name="myspace", space=dict_space)
return super().setUp()

def test_init(self):
self.test_space = ConfigurationSpace(
name="myspace",
space=dict_space_2
)
self.test_space = ConfigurationSpace(name="myspace", space=dict_space_2)

self.test_space = ConfigurationSpace(
name="myspace",
space=str_space
)
self.test_space = ConfigurationSpace(name="myspace", space=str_space)

def test_config_spaces(self):
try:
Expand Down

0 comments on commit 897f373

Please sign in to comment.