Beispiel #1
0
def test_permute_rows2():
    h = Hub([0, 1, 2, 3, 4], [0, 1, 2, [3, 4]], [1, 2, 3, 4, 5], 0)

    h.connection_table = np.array([[1, 1, 0, 0, 0], [1, 1, 0, 0, 0],
                                   [0, 0, 1, 1, 1], [0, 1, 1, 1, 0],
                                   [0, 0, 1, 1, 1]])
    h.permute_rows()
    assert h.flat_sources == [0, 1, 3, 4, 2]
    assert h.perm == [0, 1, 3, 4, 2]
    # noinspection PyTypeChecker
    assert np.all(h.connection_table == np.array(
        [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 1, 1],
         [0, 0, 1, 1, 1]]))
def test_permute_rows2():
    h = Hub([0, 1, 2, 3, 4], [0, 1, 2, [3, 4]], [1, 2, 3, 4, 5], 0)

    h.connection_table = np.array([
        [1, 1, 0, 0, 0],
        [1, 1, 0, 0, 0],
        [0, 0, 1, 1, 1],
        [0, 1, 1, 1, 0],
        [0, 0, 1, 1, 1]])
    h.permute_rows()
    assert h.flat_sources == [0, 1, 3, 4, 2]
    assert h.perm == [0, 1, 3, 4, 2]
    # noinspection PyTypeChecker
    assert np.all(h.connection_table == np.array([
        [1, 1, 0, 0, 0],
        [1, 1, 0, 0, 0],
        [0, 1, 1, 1, 0],
        [0, 0, 1, 1, 1],
        [0, 0, 1, 1, 1]]))