Пример #1
0
def test_generate_symmetric_matrix():
    matrix = generate_symmetric_matrix(n_unique_action=3, random_state=1)
    assert matrix.shape == (3, 3)
    assert np.allclose(matrix, matrix.T)
Пример #2
0
        action_interaction_weight_matrix.shape[0],
    )
    if reward_type == "binary":
        assert np.all(0 <= expected_reward_factual) and np.all(
            expected_reward_factual <= 1
        )


# context, action_context, action, base_reward_function, action_interaction_weight_matrix, reward_type, is_cascade, len_list, random_state, err, description
invalid_input_of_action_interaction_reward_function = [
    (
        np.array([5, 2]),
        np.ones([4, 2]),
        np.tile(np.arange(3), 5),
        logistic_reward_function,
        generate_symmetric_matrix(n_unique_action=4, random_state=1),
        "binary",
        True,
        3,
        1,
        ValueError,
        "context must be 2-dimensional ndarray",
    ),
    (
        np.ones([5, 2]),
        np.array([4, 2]),
        np.tile(np.arange(3), 5),
        logistic_reward_function,
        generate_symmetric_matrix(n_unique_action=4, random_state=1),
        "binary",
        True,