def _mask_edges_weights(edges, weights, mask):
 mask0 = np.hstack((mask[:, :, :(-1)].ravel(), mask[:, :(-1)].ravel(), mask[:(-1)].ravel()))
 mask1 = np.hstack((mask[:, :, 1:].ravel(), mask[:, 1:].ravel(), mask[1:].ravel()))
 ind_mask = np.logical_and(mask0, mask1)
 (edges, weights) = (edges[:, ind_mask], weights[ind_mask])
 max_node_index = edges.max()
 order = np.searchsorted(np.unique(edges.ravel()), np.arange((max_node_index + 1)))
 edges = order[edges.astype(np.int64)]
 return (edges, weights)

def _mask_edges_weights ( edges , weights , mask ) : mask0 = np . hstack ( ( mask [ : , : , : ( - 1 ) ] . ravel ( ) , mask [ : , : ( - 1 ) ] . ravel ( ) , mask [ : ( - 1 ) ] . ravel ( ) ) ) mask1 = np . hstack ( ( mask [ : , : , 1 : ] . ravel ( ) , mask [ : , 1 : ] . ravel ( ) , mask [ 1 : ] . ravel ( ) ) ) ind_mask = np . logical_and ( mask0 , mask1 ) ( edges , weights ) = ( edges [ : , ind_mask ] , weights [ ind_mask ] ) max_node_index = edges . max ( ) order = np . searchsorted ( np . unique ( edges . ravel ( ) ) , np . arange ( ( max_node_index + 1 ) ) ) edges = order [ edges . astype ( np . int64 ) ] return ( edges , weights )
apply a mask to edges .