Exemplo n.º 1
0
def test_pcs_efficient_false_dense_output_false():
    output = pairwise_cosine_similarity(A=A,
                                        B=B,
                                        efficient=False,
                                        dense_output=False)
    assert isspmatrix(output), "The output is not sparse."
    assert output.sum() == approx(8.202465881449182), "Output not correct."
Exemplo n.º 2
0
def test_pcs_efficient_true_multi_dimensional():

    output_1 = pairwise_cosine_similarity(A=E,
                                          B=F,
                                          efficient=True,
                                          n_top=3,
                                          lower_bound=0.1,
                                          n_jobs=-1,
                                          dense_output=True)
    output_2 = pairwise_cosine_similarity(A=G,
                                          B=H,
                                          efficient=True,
                                          n_top=3,
                                          lower_bound=0.1,
                                          n_jobs=-1,
                                          dense_output=True)
    assert output_1.sum() == approx(output_2.sum()), "Multi-dimensional error."
Exemplo n.º 3
0
def test_pcs_efficient_true_n_jobs():

    output = pairwise_cosine_similarity(A=A,
                                        B=B,
                                        efficient=True,
                                        n_top=4,
                                        lower_bound=0.0,
                                        n_jobs=-1,
                                        dense_output=True)
    assert output.sum() == approx(8.202465881449182), "Output not correct."

    output = pairwise_cosine_similarity(A=A,
                                        B=B,
                                        efficient=True,
                                        n_top=4,
                                        lower_bound=0.0,
                                        n_jobs=1,
                                        dense_output=True)
    assert output.sum() == approx(8.202465881449182), "Output not correct."
Exemplo n.º 4
0
def test_pcs_efficient_true_dense_output_true():
    output = pairwise_cosine_similarity(A=A,
                                        B=B,
                                        efficient=True,
                                        n_top=4,
                                        lower_bound=0.0,
                                        n_jobs=2,
                                        dense_output=True)
    assert not isspmatrix(output), "The output is sparse."
    assert output.sum() == approx(8.202465881449182), "Output not correct."
Exemplo n.º 5
0
def test_pcs_efficient_true_sparse():

    output = pairwise_cosine_similarity(A=C,
                                        B=D,
                                        efficient=True,
                                        n_top=2,
                                        lower_bound=0.1,
                                        n_jobs=-1,
                                        dense_output=True)
    assert output.sum() == approx(126.79083764959829), "Sparse input error."
Exemplo n.º 6
0
def test_pcs_efficient_true_n_top():

    output = pairwise_cosine_similarity(A=A,
                                        B=B,
                                        efficient=True,
                                        n_top=2,
                                        lower_bound=0.1,
                                        n_jobs=-1,
                                        dense_output=True)
    assert (output > 0).sum() == 6, "Error in n_top."
Exemplo n.º 7
0
def test_pcs_efficient_true_lower_bound():

    output = pairwise_cosine_similarity(A=A,
                                        B=B,
                                        efficient=True,
                                        n_top=4,
                                        lower_bound=0.9,
                                        n_jobs=-1,
                                        dense_output=True)
    assert (output > 0).sum() == 5, "Error in lower_bound."

    output = pairwise_cosine_similarity(A=A,
                                        B=B,
                                        efficient=True,
                                        n_top=4,
                                        lower_bound=0.99,
                                        n_jobs=-1,
                                        dense_output=True)
    assert (output > 0).sum() == 1, "Error in lower_bound."