def test_unsupported_discrete_prior(): """Test unsupported discrete prior message""" dim = Integer("yolo", "norm", 0, 1) with pytest.raises(TypeError) as exc: discrete_grid(dim, 6) assert exc.match("Grid Search only supports `loguniform`, `uniform`")
def test_too_small_distrete_grid(): """Test that small discrete grid does not lead to duplicates""" dim = Integer("yolo", "uniform", -2, 4) assert discrete_grid(dim, 3) == [-2, 0, 2] assert discrete_grid(dim, 5) == [-2, -1, 0, 1, 2] assert discrete_grid(dim, 50) == [-2, -1, 0, 1, 2]
def test_log_discrete_grid(): """Test log discrete grid""" dim = Integer("yolo", "reciprocal", 1, 1000) assert discrete_grid(dim, 4) == [1, 10, 100, 1000] assert discrete_grid(dim, 6) == [1, 4, 16, 63, 251, 1000]
def test_discrete_grid(): """Test discrete grid""" dim = Integer("yolo", "uniform", -5, 10) assert discrete_grid(dim, 6) == [-5, -3, -1, 1, 3, 5] assert discrete_grid(dim, 7) == [-5, -3, -2, 0, 2, 3, 5]