Ejemplo n.º 1
0
 def test_propose_without_add(self, randint_mock):
     index = 0
     randint_mock.return_value = index
     proposed = np.argmax(self.dpp_matrix[0])  # 14
     recommender = Recommender(self.dpp_matrix, self.n_components)
     np.testing.assert_array_equal(
         recommender.matching_dataset,
         self.dpp_matrix[index, :],
     )
     pipeline_index = recommender.propose()
     randint_mock.assert_called_once_with(4)  # 4 is self.dpp_matrix length
     assert pipeline_index == proposed
Ejemplo n.º 2
0
    def test_propose_done(self, predict_mock, get_candidates_mock):
        # Set-up
        recommender = Recommender(self.dpp_matrix, self.n_components)

        get_candidates_mock.return_value = None

        # Run
        params = recommender.propose()

        # Assert
        expected_params = None
        assert params == expected_params
Ejemplo n.º 3
0
 def test_propose_empty_add(self, randint_mock):
     index = 0
     randint_mock.return_value = index
     proposed = np.argmax(self.dpp_matrix[0])  # 14
     recommender = Recommender(self.dpp_matrix, self.n_components)
     recommender.add({})
     np.testing.assert_array_equal(
         recommender.matching_dataset,
         self.dpp_matrix[index, :],
     )
     pipeline_index = recommender.propose()
     assert randint_mock.call_count == 2
     assert pipeline_index == proposed
Ejemplo n.º 4
0
    def test_propose_once(self, predict_mock, get_candidates_mock):
        """n == 1"""
        # Set-up
        recommender = Recommender(self.dpp_matrix, self.n_components)

        get_candidates_mock.return_value = [1, 3, 7, 8]

        predict_mock.return_value = np.array([1, 4, 2, 3])

        # Run
        pipeline_index = recommender.propose()

        # Assert
        expected_pipeline_index = 3
        assert pipeline_index == expected_pipeline_index