Beispiel #1
0
    def test__get_next_tunable_name_normalized_scores(self, mock_np_random_choice):
        # setup
        mock_np_random_choice.return_value = 'test_name'
        selector = MagicMock()
        selector.select.return_value = 'test_name'

        instance = MagicMock(spec_set=BTBSession)
        instance._normalized_scores = [('test_name', 0.1), ('second_test_name', 0.2)]
        instance._selector = selector

        # run
        tunable_name = BTBSession._get_next_tunable_name(instance)

        # assert
        assert tunable_name == 'test_name'
        mock_np_random_choice.assert_not_called()
        selector.select.assert_called_once_with([
            ('test_name', 0.1),
            ('second_test_name', 0.2),
        ])
Beispiel #2
0
    def test__get_next_tunable_name_normalized_scores_none(self, mock_np_random_choice):
        # setup
        mock_np_random_choice.return_value = 'test_name'

        instance = MagicMock(spec_set=BTBSession)
        instance._normalized_scores = None
        instance._tunables = {
            'test_name': 'test',
            'second_test_name': 'second_test',
        }

        # python3.5 randomness issue, we read as in `btb.session`
        expected_mock_call = list(instance._tunables.keys())

        # run
        tunable_name = BTBSession._get_next_tunable_name(instance)

        # assert

        assert tunable_name == 'test_name'
        mock_np_random_choice.assert_called_once_with(expected_mock_call)