Exemplo n.º 1
0
def test_mixture_search_space_ok():
    search_space = {
        "weights": [0.5, 0.5],
        "parameters": [
            {
                "category": "normal",
                "search_space": {
                    "mu": 0.5,
                    "sigma": 1,
                    "low": -5,
                    "high": 5,
                    "step": 0.1
                },
            },
            {
                "category": "categorical",
                "search_space": {
                    "values": [1, 2, 3],
                    "probabilities": [0.1, 0.2, 0.7]
                },
            },
        ],
    }

    search_space = validate_mixture(search_space)
Exemplo n.º 2
0
def test_mixture_search_space_missing_category():
    search_space = {
        "weights": [0.5, 0.5],
        "parameters": [
            {
                # "category": "normal",
                "search_space": {
                    "mu": 0.5,
                    "sigma": 1,
                    "low": -5,
                    "high": 5,
                    "step": 0.1
                }
            },
            {
                "category": "categorical",
                "search_space": {
                    "values": [1, 2, 3],
                    "probabilities": [0.1, 0.2, 0.7]
                },
            },
        ],
    }

    with pytest.raises(ValidationError):
        search_space = validate_mixture(search_space)
Exemplo n.º 3
0
def test_mixture_search_space_no_parameters():
    search_space = {
        "weights": [0.5, 0.5],
        # "parameters": [
        #     {
        #         "category": "normal",
        #         "search_space": {
        #             "mu": 0.5,
        #             "sigma": 1,
        #             "low": -5,
        #             "high": 5,
        #             "step": 0.1,
        #         }
        #     },
        #     {
        #         "category": "categorical",
        #         "search_space": {
        #             "values": [1, 2, 3],
        #             "probabilities": [0.1, 0.2, 0.7]
        #         }
        #     }
        # ]
    }

    with pytest.raises(ValidationError):
        search_space = validate_mixture(search_space)
Exemplo n.º 4
0
def test_mixture_search_space_no_weights():
    search_space = {
        "parameters": [
            {
                "category": "normal",
                "search_space": {
                    "mu": 0.5,
                    "sigma": 1,
                    "low": -5,
                    "high": 5,
                    "step": 0.1
                },
            },
            {
                "category": "categorical",
                "search_space": {
                    "values": [1, 2, 3],
                    "probabilities": [0.1, 0.2, 0.7]
                },
            },
        ]
    }

    search_space = validate_mixture(search_space)

    assert "weights" in search_space.keys()
    assert sum(search_space["weights"]) == 1
Exemplo n.º 5
0
def test_mixture_search_space_bad_parameters():
    search_space = {
        "weights": [0.5, 0.5],
        "parameters": {
            "category": "normal",
            "search_space": {
                "mu": 0.5,
                "sigma": 1,
                "low": -5,
                "high": 5,
                "step": 0.1
            },
        },
    }

    with pytest.raises(ValidationError):
        search_space = validate_mixture(search_space)
Exemplo n.º 6
0
def test_mixture_search_space_bad_search_space():
    search_space = {
        "weights": [0.5, 0.5],
        "parameters": [{
            "category": "normal",
            "search_space": ["lol"]
        }, {
            "category": "categorical",
            "search_space": {
                "values": [1, 2, 3],
                "probabilities": [0.1, 0.2, 0.7]
            }
        }]
    }

    with pytest.raises(ValidationError):
        search_space = validate_mixture(search_space)
Exemplo n.º 7
0
def test_mixture_search_space_bad():
    search_space = ["bma"]

    with pytest.raises(ValidationError):
        search_space = validate_mixture(search_space)