Skip to content

Commit

Permalink
enhancement: test for search space encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
amsks committed Dec 11, 2023
1 parent 1a72211 commit 4a15397
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/test_search_space_encoding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import unittest

from carl.context.search_space_encoding import search_space_to_config_space
from ConfigSpace import ConfigurationSpace
from omegaconf import DictConfig


class TestSearchSpacEncoding(unittest.TestCase):
def setUp(self):
self.test_space = None
self.test_space = ConfigurationSpace(
name="myspace",
space={
"uniform_integer": (1, 10),
"uniform_float": (1.0, 10.0),
"categorical": ["a", "b", "c"],
"constant": 1337,
},
)
return super().setUp()

def test_config_spaces(self):
try:
search_space_to_config_space(self.test_space)
except Exception as e:
print(f"Cannot encode search space -- {self.test_space}.")
raise e

def test_dict_configs(self):
try:
dict_space = DictConfig({"hyperparameters": {}})

search_space_to_config_space(dict_space)
except Exception as e:
print(f"Cannot encode search space -- {dict_space}.")
raise e


if __name__ == "__main__":
unittest.main()

0 comments on commit 4a15397

Please sign in to comment.