<commit_before>import numpy as np
import sys
import nrrd
import scipy.stats

if (len(sys.argv) < 4):
    print 'Error: missing arguments!'
else:

    print 'Checking alignment for ', str(sys.argv[1]), ' against the template (', str(sys.argv[2]), ')...'
  
    data1, header1 = nrrd.read(str(sys.argv[2]))
        
    data2, header2 = nrrd.read(str(sys.argv[1])) 
    
    Nd1 = np.squeeze(np.asarray(data1,dtype=np.float128))
    Nd2 = np.squeeze(np.asarray(data2,dtype=np.float128))
                                        
    r=np.sum(np.multiply(np.subtract(Nd1,np.average(Nd1)),np.subtract(Nd2,np.average(Nd2))))/np.sqrt(np.multiply(np.sum(np.square(np.subtract(Nd1,np.average(Nd1)))),np.sum(np.square(np.subtract(Nd2,np.average(Nd2))))))
      
    print 'The alignment has a Object Pearson\'s Coefficient r value of: %0.60f (1=perfect)'% r
    
    print 'Outputing results to ', str(sys.argv[3])
    
    with open(str(sys.argv[3]), "a") as myfile: 
        myfile.write('{0:.100f}'.format(r) + ', Object Pearson Coefficent, ' + str(sys.argv[1]) + ', ' + str(sys.argv[2]) + '\n')<commit_msg>Update ObjPearsonCoeff.py<commit_after>import numpy as np
import sys
import nrrd
import scipy.stats

if (len(sys.argv) < 4):
    print 'Error: missing arguments!'
else:

    print 'Checking alignment for ', str(sys.argv[1]), ' against the template (', str(sys.argv[2]), ')...'
  
    data1, header1 = nrrd.read(str(sys.argv[2]))
        
    data2, header2 = nrrd.read(str(sys.argv[1])) 
    
    Nd1 = np.squeeze(np.asarray(data1,dtype=np.float128))
    Nd2 = np.squeeze(np.asarray(data2,dtype=np.float128))
    
    th = 0
    
    for i in range(0,size(Nd1)):
        if ((Nd1[i] > th) or (Nd2 > th)):
            Na1[i] = Nd1[i]
            Na2[i] = Nd2[i]
            
                                        
    r=np.sum(np.multiply(np.subtract(Nd1,np.average(Na1)),np.subtract(Nd2,np.average(Na2))))/np.sqrt(np.multiply(np.sum(np.square(np.subtract(Nd1,np.average(Na1)))),np.sum(np.square(np.subtract(Nd2,np.average(Na2))))))
      
    print 'The alignment has a Object Pearson\'s Coefficient r value of: %0.60f (1=perfect)'% r
    
    print 'Outputing results to ', str(sys.argv[3])
    
    with open(str(sys.argv[3]), "a") as myfile: 
        myfile.write('{0:.100f}'.format(r) + ', Object Pearson Coefficent, ' + str(sys.argv[1]) + ', ' + str(sys.argv[2]) + '\n')
{'fraction_non_alphanumeric': 0.18384518300378627, 'fraction_numerical': 0.036600757257046694, 'mean_word_length': 2.943615257048093, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2083615', 'n_tokens_mistral': 958, 'n_tokens_neox': 915, 'n_words': 154}