<commit_before>"""Generic utilities that may be needed by the other modules.
"""

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
from __future__ import print_function

import warnings

import numpy as np
import networkx as nx

#-----------------------------------------------------------------------------
# Functions
#-----------------------------------------------------------------------------
def format_matrix(data,s,b,lk,co,idc = [],costlist=[],nouptri = False):
    """ Function which formats matrix for a particular subject and particular block (thresholds, upper-tris it) so that we can make a graph object out of it

    Parameters:
    -----------
    data = full data array
    s = subject
    b = block
    lk = lookup table for study
    co = cost value to threshold at
"""

    cmat = data[b,s]
    th = cost2thresh(co,s,b,lk,[],idc,costlist) #get the right threshold
    
    #cmat = replace_diag(cmat) #replace diagonals with zero
    cmat = thresholded_arr(cmat,th,fill_val=0)

    if not nouptri:<commit_msg>BF: remove [] from call to cost2thresh in format_matrix, as it is not an input to the function<commit_after>"""Generic utilities that may be needed by the other modules.
"""

#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
from __future__ import print_function

import warnings

import numpy as np
import networkx as nx

#-----------------------------------------------------------------------------
# Functions
#-----------------------------------------------------------------------------
def format_matrix(data,s,b,lk,co,idc = [],costlist=[],nouptri = False):
    """ Function which formats matrix for a particular subject and particular block (thresholds, upper-tris it) so that we can make a graph object out of it

    Parameters:
    -----------
    data = full data array
    s = subject
    b = block
    lk = lookup table for study
    co = cost value to threshold at
"""

    cmat = data[b,s]
    th = cost2thresh(co,s,b,lk,idc,costlist) #get the right threshold
    
    #cmat = replace_diag(cmat) #replace diagonals with zero
    cmat = thresholded_arr(cmat,th,fill_val=0)

    if not nouptri:
{'fraction_non_alphanumeric': 0.33403538331929233, 'fraction_numerical': 0.0021061499578770007, 'mean_word_length': 1.3375984251968505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6835805', 'n_tokens_mistral': 580, 'n_tokens_neox': 561, 'n_words': 203}