Example #1
0
    def test_composite_adapter_forward(self, dummy_param, trials):
        """Test :meth:`orion.core.evc.adapters.CompositeAdapter.forward` with two adapters"""
        new_param = Trial.Param(name="second_normal_prior",
                                type="integer",
                                value=1)

        dimension_addition_adapter = DimensionAddition(new_param)
        dimension_deletion_adapter = DimensionDeletion(new_param)

        composite_adapter = CompositeAdapter(dimension_addition_adapter)

        adapted_trials = composite_adapter.forward(trials)

        assert adapted_trials[0]._params[-1] == new_param
        assert adapted_trials[4]._params[-1] == new_param
        assert adapted_trials[-1]._params[-1] == new_param

        composite_adapter = CompositeAdapter(dimension_addition_adapter,
                                             dimension_deletion_adapter)

        adapted_trials = composite_adapter.forward(trials)

        assert len(adapted_trials) == len(trials)

        assert new_param not in (adapted_trials[0]._params)
        assert new_param not in (adapted_trials[4]._params)
        assert new_param not in (adapted_trials[-1]._params)
Example #2
0
    def test_composite_adapter_forward_emtpy(self, trials):
        """Test :meth:`orion.core.evc.adapters.CompositeAdapter.forward` and
        :meth:`orion.core.evc.adapters.CompositeAdapter.backward` with no adapters
        """
        composite_adapter = CompositeAdapter()

        assert len(composite_adapter.forward(trials)) == len(trials)
        assert len(composite_adapter.backward(trials)) == len(trials)