diff --git a/python/ray/tune/suggest/hyperopt.py b/python/ray/tune/suggest/hyperopt.py index 953fb4bb1..133dc1da3 100644 --- a/python/ray/tune/suggest/hyperopt.py +++ b/python/ray/tune/suggest/hyperopt.py @@ -361,17 +361,7 @@ class HyperOptSearch(Searcher): logger.warning( "HyperOpt does not support quantization for " "integer values. Reverting back to 'randint'.") - if domain.lower != 0: - raise ValueError( - "HyperOpt only allows integer sampling with " - f"lower bound 0. Got: {domain.lower}.") - if domain.upper < 1: - raise ValueError( - "HyperOpt does not support integer sampling " - "of values lower than 0. Set your maximum range " - "to something above 0 (currently {})".format( - domain.upper)) - return hpo.hp.randint(par, domain.upper) + return hpo.hp.randint(par, domain.lower, high=domain.upper) elif isinstance(domain, Categorical): if isinstance(sampler, Uniform): return hpo.hp.choice(par, [ diff --git a/python/ray/tune/tests/test_sample.py b/python/ray/tune/tests/test_sample.py index f8951aa13..af79684fe 100644 --- a/python/ray/tune/tests/test_sample.py +++ b/python/ray/tune/tests/test_sample.py @@ -412,7 +412,7 @@ class SearchSpaceTest(unittest.TestCase): config = { "a": tune.sample.Categorical([2, 3, 4]).uniform(), "b": { - "x": tune.sample.Integer(0, 5).quantized(2), + "x": tune.sample.Integer(-15, -10).quantized(2), "y": 4, "z": tune.sample.Float(1e-4, 1e-2).loguniform() } @@ -421,7 +421,7 @@ class SearchSpaceTest(unittest.TestCase): hyperopt_config = { "a": hp.choice("a", [2, 3, 4]), "b": { - "x": hp.randint("x", 5), + "x": hp.randint("x", -15, -10), "y": 4, "z": hp.loguniform("z", np.log(1e-4), np.log(1e-2)) } @@ -443,7 +443,7 @@ class SearchSpaceTest(unittest.TestCase): self.assertEqual(config1, config2) self.assertIn(config1["a"], [2, 3, 4]) - self.assertIn(config1["b"]["x"], list(range(5))) + self.assertIn(config1["b"]["x"], list(range(-15, -10))) self.assertEqual(config1["b"]["y"], 4) self.assertLess(1e-4, config1["b"]["z"]) self.assertLess(config1["b"]["z"], 1e-2) diff --git a/python/requirements_tune.txt b/python/requirements_tune.txt index c87eafa9b..794c0520f 100644 --- a/python/requirements_tune.txt +++ b/python/requirements_tune.txt @@ -7,7 +7,7 @@ gym[atari] GPy h5py hpbandster -hyperopt==0.1.2 +hyperopt>=0.2.5 jupyter keras kubernetes