예제 #1
0
    def test_code_change_backward_break(self, trials):
        """Test :meth:`orion.core.evc.adapters.CodeChange.backward` with change type BREAK"""
        code_change_adapter = CodeChange(CodeChange.BREAK)

        adapted_trials = code_change_adapter.backward(trials)

        assert len(adapted_trials) == 0
예제 #2
0
    def test_code_change_backward_unsure(self, trials):
        """Test :meth:`orion.core.evc.adapters.CodeChange.backward` with change type UNSURE"""
        code_change_adapter = CodeChange(CodeChange.UNSURE)

        adapted_trials = code_change_adapter.backward(trials)

        assert len(adapted_trials) == 0
예제 #3
0
    def test_code_change_init(self):
        """Test initialization of :class:`orion.core.evc.adapters.CodeChange`
        with valid change types
        """
        code_change_adapter = CodeChange(CodeChange.NOEFFECT)
        assert code_change_adapter.change_type == CodeChange.NOEFFECT

        code_change_adapter = CodeChange(CodeChange.BREAK)
        assert code_change_adapter.change_type == CodeChange.BREAK
예제 #4
0
    def test_code_change_backward_noeffect(self, trials):
        """Test :meth:`orion.core.evc.adapters.CodeChange.backward` with change type NOEFFECT"""
        code_change_adapter = CodeChange(CodeChange.NOEFFECT)

        adapted_trials = code_change_adapter.backward(trials)

        assert len(adapted_trials) == len(trials)

        assert adapted_trials[0] is trials[0]
        assert adapted_trials[-1] is trials[-1]
예제 #5
0
    def test_code_change_init_bad_type(self):
        """Test initialization of :class:`orion.core.evc.adapters.CodeChange`
        with invalid change types
        """
        with pytest.raises(ValueError) as exc_info:
            CodeChange("bad type")

        assert "Invalid code change type 'bad type'" in str(exc_info.value)
예제 #6
0
def test_code_change_configuration():
    """Test :meth:`orion.core.evc.adapters.CodeChange.configuration`"""
    code_change_adaptor = CodeChange(CodeChange.UNSURE)

    configuration = code_change_adaptor.configuration[0]

    assert configuration["of_type"] == "codechange"
    assert configuration["change_type"] == CodeChange.UNSURE

    assert (BaseAdapter.build(
        [configuration]).adapters[0].configuration[0] == configuration)