def get_sorted_solutions_indexes_test(): mocked_pb_response = build_mocked_response() candidates_pool, sections_set = new_default._build_candidate_pool_and_sections_set( mocked_pb_response) selected_sections_matrix = new_default._build_selected_sections_matrix( sections_set, candidates_pool) best_indexes, selection_matrix = new_default._get_sorted_solutions_indexes( selected_sections_matrix, 5) assert best_indexes.shape[0] == 27 assert all(selection_matrix[best_indexes[0]] == [0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0])
def get_sorted_solutions_indexes_test(): mocked_pb_response = build_mocked_response() candidates_pool, sections_set, idx_jrny_must_keep = new_default._build_candidate_pool_and_sections_set( mocked_pb_response.journeys ) selected_sections_matrix = new_default._build_selected_sections_matrix(sections_set, candidates_pool) # 4 journeys are must-have, we'd like to select another 5 journeys best_indexes, selection_matrix = new_default._get_sorted_solutions_indexes( selected_sections_matrix, (5 + 4), idx_jrny_must_keep ) assert best_indexes.shape[0] == 33 assert all(selection_matrix[best_indexes[0]] == [0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0])