<commit_before>cimport numpy as np


###
# Just Threshold (Pour Eigenvector Centrality)
###

# Un-Weighted
def thresh_binarize_float(np.ndarray[float, ndim=2] cmat, float thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(i,cmat.shape[1]):
            cmat[i,j] = cmat[j,i] = 1 * (cmat[i,j] > thresh)

def thresh_binarize_double(np.ndarray[double, ndim=2] cmat, double thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(i,cmat.shape[1]):
            cmat[i,j] = cmat[j,i] = 1 * (cmat[i,j] > thresh)

# Weighted
def thresh_weighted_float(np.ndarray[float, ndim=2] cmat, float thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(i,cmat.shape[1]):
            cmat[i,j] = cmat[j,i] = cmat[i,j] * (cmat[i,j] > thresh)

def thresh_weighted_double(np.ndarray[double, ndim=2] cmat, double thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(i,cmat.shape[1]):
            cmat[i,j] = cmat[j,i] = cmat[i,j] * (cmat[i,j] > thresh)

# Weighted and Transform
def thresh_transform_weighted_float(np.ndarray[float, ndim=2] cmat, float thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(i,cmat.shape[1]):
            cmat[i,j] = cmat[j,i] = (1.0+cmat[i,j])/2.0 * (cmat[i,j] > thresh)

def thresh_transform_weighted_double(np.ndarray[double, ndim=2] cmat, double thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(i,cmat.shape[1]):
            cmat[i,j] = cmat[j,i] = (1.0+cmat[i,j])/2.0 * (cmat[i,j] > thresh)


###
# Threshold and Sum (Degree Centrality)
###

# Un-Weighted
def centrality_binarize_float(np.ndarray[float, ndim=2] cmat, np.ndarray[float, ndim=1] cent, float thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(i,cmat.shape[1]):
            cent[i] = cent[i] + 1*(cmat[i,j] > thresh)

def centrality_binarize_double(np.ndarray[double, ndim=2] cmat, np.ndarray[double, ndim=1] cent, double thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(cmat.shape[1]):
            cent[i] = cent[i] + 1*(cmat[i,j] > thresh)

# Weighted<commit_msg>loop through every element of matrix for thresholding<commit_after>cimport numpy as np


###
# Just Threshold (Pour Eigenvector Centrality)
###

# Un-Weighted
def thresh_binarize_float(np.ndarray[float, ndim=2] cmat, float thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(cmat.shape[1]):
            cmat[i,j] = 1 * (cmat[i,j] > thresh)

def thresh_binarize_double(np.ndarray[double, ndim=2] cmat, double thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(cmat.shape[1]):
            cmat[i,j] = 1 * (cmat[i,j] > thresh)

# Weighted
def thresh_weighted_float(np.ndarray[float, ndim=2] cmat, float thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(cmat.shape[1]):
            cmat[i,j] = cmat[i,j] * (cmat[i,j] > thresh)

def thresh_weighted_double(np.ndarray[double, ndim=2] cmat, double thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(cmat.shape[1]):
            cmat[i,j] = cmat[i,j] * (cmat[i,j] > thresh)

# Weighted and Transform
def thresh_transform_weighted_float(np.ndarray[float, ndim=2] cmat, float thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(cmat.shape[1]):
            cmat[i,j] = (1.0+cmat[i,j])/2.0 * (cmat[i,j] > thresh)

def thresh_transform_weighted_double(np.ndarray[double, ndim=2] cmat, double thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(cmat.shape[1]):
            cmat[i,j] = (1.0+cmat[i,j])/2.0 * (cmat[i,j] > thresh)


###
# Threshold and Sum (Degree Centrality)
###

# Un-Weighted
def centrality_binarize_float(np.ndarray[float, ndim=2] cmat, np.ndarray[float, ndim=1] cent, float thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(i,cmat.shape[1]):
            cent[i] = cent[i] + 1*(cmat[i,j] > thresh)

def centrality_binarize_double(np.ndarray[double, ndim=2] cmat, np.ndarray[double, ndim=1] cent, double thresh):
    cdef unsigned int i,j
    for i in xrange(cmat.shape[0]):
        for j in xrange(cmat.shape[1]):
            cent[i] = cent[i] + 1*(cmat[i,j] > thresh)

# Weighted
{'fraction_non_alphanumeric': 0.15384615384615385, 'fraction_numerical': 0.016799292661361626, 'mean_word_length': 3.367760617760618, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4727892', 'n_tokens_mistral': 1921, 'n_tokens_neox': 1864, 'n_words': 418}