Beispiel #1
0
def test_dense_matrix_from_pair_dictionary():
    d = {("a", "b"): 10, ("b", "c"): 20}
    X, rows, columns = dense_matrix_from_pair_dictionary(d)
    eq_(rows, ["a", "b"])
    eq_(columns, ["b", "c"])
    eq_(X[0, 0], 10)
    assert np.isnan(X[0, 1])
    assert np.isnan(X[1, 0])
    eq_(X[1, 1], 20)
def test_dense_matrix_from_pair_dictionary():
    d = {
        ("a", "b"): 10,
        ("b", "c"): 20
    }
    X, rows, columns = dense_matrix_from_pair_dictionary(d)
    eq_(rows, ["a", "b"])
    eq_(columns, ["b", "c"])
    eq_(X[0, 0], 10)
    assert np.isnan(X[0, 1])
    assert np.isnan(X[1, 0])
    eq_(X[1, 1], 20)
Beispiel #3
0
def test_dense_matrix_from_pair_dictionary_square():
    d = {("a", "b"): 10, ("b", "c"): 20}
    X, rows, columns = dense_matrix_from_pair_dictionary(d, square_result=True)
    eq_(rows, ["a", "b", "c"])
    eq_(columns, ["a", "b", "c"])
    assert np.isnan(X[0, 0])
    eq_(X[0, 1], 10)
    assert np.isnan(X[0, 2])
    assert np.isnan(X[1, 0])
    assert np.isnan(X[1, 1])
    eq_(X[1, 2], 20)
    assert np.isnan(X[2, 0])
    assert np.isnan(X[2, 1])
    assert np.isnan(X[2, 2])
def test_dense_matrix_from_pair_dictionary_square():
    d = {
        ("a", "b"): 10,
        ("b", "c"): 20
    }
    X, rows, columns = dense_matrix_from_pair_dictionary(d, square_result=True)
    eq_(rows, ["a", "b", "c"])
    eq_(columns, ["a", "b", "c"])
    assert np.isnan(X[0, 0])
    eq_(X[0, 1], 10)
    assert np.isnan(X[0, 2])
    assert np.isnan(X[1, 0])
    assert np.isnan(X[1, 1])
    eq_(X[1, 2], 20)
    assert np.isnan(X[2, 0])
    assert np.isnan(X[2, 1])
    assert np.isnan(X[2, 2])