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_can_be_connected_with_single_buffer(): con_table = np.array([[0, 0, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1]]).T assert Hub.can_be_connected_with_single_buffer(con_table) con_table = np.array([ [0, 0, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 1, 1], [0, 1, 0, 1, 0], # < the bad boy [0, 1, 1, 1, 0], [1, 1, 1, 1, 1] ]).T assert not Hub.can_be_connected_with_single_buffer(con_table)
def test_can_be_connected_with_single_buffer(): con_table = np.array([ [0, 0, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1]]).T assert Hub.can_be_connected_with_single_buffer(con_table) con_table = np.array([ [0, 0, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 1, 1], [0, 1, 0, 1, 0], # < the bad boy [0, 1, 1, 1, 0], [1, 1, 1, 1, 1]]).T assert not Hub.can_be_connected_with_single_buffer(con_table)
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_col_can_be_connected_with_single_buffer(col, expected): assert Hub.can_be_connected_with_single_buffer( np.array(col).reshape(-1, 1)) == expected
def test_col_can_be_connected_with_single_buffer(col, expected): assert Hub.can_be_connected_with_single_buffer(np.array(col) .reshape(-1, 1)) == expected