def test_gp_3(): v = FloatVariable('name', 1, 10, 'log') assert 2.0 == v.point_from_gp(v.point_to_gp(2)) assert 1.0 == v.point_from_gp(v.point_to_gp(1)) assert 1.0 == v.point_from_gp(v.point_to_gp(0.9)) assert 10.0 == v.point_from_gp(v.point_to_gp(10)) assert 10.0 == v.point_from_gp(v.point_to_gp(10.1))
def test_gp_3(): v = FloatVariable('name', 1, 10, 'log') assert 2.0 == v.point_from_unit(v.point_to_unit(2)) assert 1.0 == v.point_from_unit(v.point_to_unit(1)) assert 1.0 == v.point_from_unit(v.point_to_unit(0.9)) assert 10.0 == v.point_from_unit(v.point_to_unit(10)) assert 10.0 == v.point_from_unit(v.point_to_unit(10.1))
def test_gp_2(): v = FloatVariable('name', 1, 10, None) assert (2-1) / (10-1) == v.point_to_unit(2) assert 0.0 == v.point_to_unit(1) assert 1.0 == v.point_to_unit(10) assert 2.0 == v.point_from_unit(v.point_to_unit(2)) assert 1.0 == v.point_from_unit(v.point_to_unit(1)) assert 1.0 == v.point_from_unit(v.point_to_unit(0.9)) assert 10.0 == v.point_from_unit(v.point_to_unit(10)) assert 10.0 == v.point_from_unit(v.point_to_unit(10.1))
def test_search_space(): config = Config.fromdict( { 'search_space': { 'intvar': { 'type': 'int', 'min': 1, 'max': 2 }, 'logivar': { 'type': 'int', 'min': 1, 'max': 2, 'warp': 'log' }, 'fvar': { 'type': 'float', 'min': 1, 'max': 3.5 }, 'logfvar': { 'type': 'float', 'min': 1, 'max': 2.5, 'warp': 'log' }, 'enumvar': { 'type': 'enum', 'choices': [1, False] }, 'jumpivar': { 'type': 'jump', 'min': 1, 'max': 3, 'num': 3, 'var_type': int }, 'jumpfvar': { 'type': 'jump', 'min': 1, 'max': 3, 'num': 3, 'var_type': float }, 'logjumpivar': { 'type': 'jump', 'min': 10, 'max': 1000, 'num': 3, 'warp': 'log', 'var_type': int }, 'logjumpfvar': { 'type': 'jump', 'min': 10, 'max': 1000, 'num': 3, 'warp': 'log', 'var_type': float } } }, check_fields=False) searchspace = config.search_space() assert searchspace['intvar'] == IntVariable('intvar', 1, 2, warp=None) assert searchspace['logivar'] == IntVariable('logivar', 1, 2, warp='log') assert searchspace['fvar'] == FloatVariable('fvar', 1, 3.5, warp=None) assert searchspace['logfvar'] == FloatVariable('logfvar', 1, 2.5, warp='log') assert searchspace['enumvar'] == EnumVariable('enumvar', [1, False]) assert searchspace['jumpivar'] == EnumVariable('jumpivar', [1, 2, 3]) assert searchspace['jumpfvar'] == EnumVariable('jumpfvar', [1.0, 2.0, 3.0]) assert searchspace['logjumpivar'] == EnumVariable('logjumpivar', [10, 100, 1000]) assert searchspace['logjumpfvar'] == EnumVariable('logjumpfvar', [10.0, 100.0, 1000.0])
def test_gp_2(): v = FloatVariable('name', 1, 10, None) assert (2-1) / (10-1) == v.point_to_gp(2) assert 0.0 == v.point_to_gp(1) assert 1.0 == v.point_to_gp(10) assert 2.0 == v.point_from_gp(v.point_to_gp(2)) assert 1.0 == v.point_from_gp(v.point_to_gp(1)) assert 1.0 == v.point_from_gp(v.point_to_gp(0.9)) assert 10.0 == v.point_from_gp(v.point_to_gp(10)) assert 10.0 == v.point_from_gp(v.point_to_gp(10.1))