def _site_percolation(network, pmask):
    r"""
    This private method is called by 'find_clusters'
    """
    # Find throats that produce site percolation
    conns = sp.copy(network['throat.conns'])
    conns[:, 0] = pmask[conns[:, 0]]
    conns[:, 1] = pmask[conns[:, 1]]
    # Only if both pores are True is the throat set to True
    tmask = sp.all(conns, axis=1)

    # Perform the clustering using scipy.csgraph
    csr = network.create_adjacency_matrix(weights=tmask, fmt='csr',
                                          drop_zeros=True)
    clusters = sprs.csgraph.connected_components(csgraph=csr,
                                                 directed=False)[1]

    # Adjust cluster numbers such that non-invaded pores are labelled -1
    # Note: The following line also takes care of assigning cluster numbers
    # to single isolated invaded pores
    p_clusters = (clusters + 1)*(pmask) - 1
    # Label invaded throats with their neighboring pore's label
    t_clusters = clusters[network['throat.conns']]
    ind = (t_clusters[:, 0] == t_clusters[:, 1])
    t_clusters = t_clusters[:, 0]
    # Label non-invaded throats with -1
    t_clusters[~ind] = -1

    return (p_clusters, t_clusters)
def _site_percolation ( network , pmask ) : conns = sp . copy ( network [ 'throat.conns' ] ) conns [ : , 0 ] = pmask [ conns [ : , 0 ] ] conns [ : , 1 ] = pmask [ conns [ : , 1 ] ] tmask = sp . all ( conns , axis = 1 ) csr = network . create_adjacency_matrix ( weights = tmask , fmt = 'csr' , drop_zeros = True ) clusters = sprs . csgraph . connected_components ( csgraph = csr , directed = False ) [ 1 ] p_clusters = ( clusters + 1 ) * ( pmask ) - 1 t_clusters = clusters [ network [ 'throat.conns' ] ] ind = ( t_clusters [ : , 0 ] == t_clusters [ : , 1 ] ) t_clusters = t_clusters [ : , 0 ] t_clusters [ ~ ind ] = - 1 return ( p_clusters , t_clusters )
r"""
    This private method is called by 'find_clusters'