Beispiel #1
0
def test_add_lines2():
    nlines = 1e5
    ncols = 1
    A = np.random.rand(nlines, ncols)
    B = np.random.rand(nlines, ncols)
    I = np.asarray(np.random.randint(nlines, size=nlines)
            ).astype(np.int)
    C1 = B.copy()
    C2 = B.copy()
    routines.add_lines(A, C1, I)
    slow_add_lines(A, C2, I)
    assert_almost_equal(C1, C2)
Beispiel #2
0
def isolated(XYZ, k=18):
    """
    Outputs an index I of isolated points from their integer coordinates,
    XYZ (3, n), and under k-connectivity, k = 6, 18 or 24.
    """
    A, B, D = FG.graph_3d_grid(XYZ.transpose(),k)
    # Number of vertices
    V = max(A) + 1
    # Labels of connected components
    label = FG.graph_cc(A,B,D,V)
    # Isolated points
    ncc = label.max() + 1
    p = XYZ.shape[1]
    size = np.zeros(ncc, float)
    ones = np.ones((p, 1), float)
    add_lines(ones, size.reshape(ncc, 1), label)
    return np.where(size[label] == 1)[0]