def test_subspace(backend): space = Space(backend=backend) space.normal('a', 1, 2, quantization=0.01) subspace = space.subspace('b') subspace.normal('a', 1, 2, quantization=0.01) print(space.sample())
def test_normal(backend): for discrete in [True, False]: for log in [True, False]: for q in [None, 0.01, 1]: space = Space(backend=backend) space.normal(f'a_{discrete}_{log}_{q}', loc=1, scale=2, discrete=discrete, log=log, quantization=q) try: print(space.sample()) except NotImplementedError: assert backend == 'Orion' and log is True
def test_conditions_or(): space = Space('ConfigSpace') a = space.normal('a', 1, 2, quantization=0.01) b = space.normal('b', 1, 2, quantization=0.01) b.enable_if(either(eq(a, 1), ne(a, 2))) print(space.sample())
def test_conditions_and(): space = Space('ConfigSpace') a = space.normal('a', 1, 2, quantization=0.01) b = space.normal('b', 1, 2, quantization=0.01) b.enable_if(both(gt(a, 1), lt(a, 2))) print(space.sample())
def test_conditions_in(): space = Space('ConfigSpace') a = space.normal('a', 1, 2, quantization=0.01) b = space.normal('b', 1, 2, quantization=0.01) b.enable_if(contains(a, [1, 1.5, 2])) print(space.sample())
def test_conditions(condition): space = Space('ConfigSpace') a = space.normal('a', 1, 2, quantization=0.01) b = space.normal('b', 1, 2, quantization=0.01) b.enable_if(condition(a, 1.5)) print(space.sample())