<commit_before>import scipy.io as sio
from glob import glob
import os
import numpy as np
import argparse

def main():

  parser = argparse.ArgumentParser(description='Get GLOBAL number of edges and vertices for directory of graphs')
  parser.add_argument('grDir', action='store',help='Full filename sparse graph (.mat) directory')
  parser.add_argument('saveDir', action='store', help='Full path of directory where you want .npy array resulting files to go')

  result = parser.parse_args()
  countVerticesAndEdges(result.G_fn, result.saveDir)

def countVerticesAndEdges(grDir, saveDir):
  numvertices = []
  numEdges = []

  if not os.path.exists(saveDir):
    os.makedirs(saveDir)
    print 'Directory created --> %s'

  for f in glob(os.path.join(grDir,"*")):
    G = sio.loadmat(f)['fibergraph']
    numvertices.append(G.shape[0]) # gets global num edges

    edgeCount = 0 # Individual count of edge per graph
    for vertex in  G.shape[0]:
      edgeCount += G[0].nnz
    numEdges.append(edgeCount)

    import pdb; pdb.set_trace()

  np.save(os.path.join(saveDir, 'numVerices'), np.array(numvertices)) # save the number of vertices
  np.save(os.path.join(saveDir, 'numEdges'), np.array(numEdges)) # save the number of edges

if __name__ == '__main__':
  main()<commit_msg>dict not list anymore<commit_after>import scipy.io as sio
from glob import glob
import os
import numpy as np
import argparse

def main():

  parser = argparse.ArgumentParser(description='Get GLOBAL number of edges and vertices for directory of graphs')
  parser.add_argument('grDir', action='store',help='Full filename sparse graph (.mat) directory')
  parser.add_argument('saveDir', action='store', help='Full path of directory where you want .npy array resulting files to go')

  result = parser.parse_args()
  countVerticesAndEdges(result.G_fn, result.saveDir)

def root(arrfn):
  return (arrfn.split('/')[-1]).split('_')[0]

def countVerticesAndEdges(grDir, saveDir):

  numVertDict = {}
  numEdgesDict = {}

  if not os.path.exists(saveDir):
    os.makedirs(saveDir)
    print 'Directory created --> %s'

  for f in glob(os.path.join(grDir,"*")):
    G = sio.loadmat(f)['fibergraph']
    numVertDict[root(f)] = G.shape[0]

    edgeCount = 0 # Individual count of edge per graph
    for vertex in G.shape[0]:
      edgeCount += G[0].nnz
    numEdgesDict[root(f)] = edgeCount

  np.save(os.path.join(saveDir, 'numVericesDict'), np.array(numVericesDict)) # save the number of vertices
  np.save(os.path.join(saveDir, 'numEdgesDict'), np.array(numEdgesDict)) # save the number of edges

if __name__ == '__main__':
  main()
{'fraction_non_alphanumeric': 0.1291314373558801, 'fraction_numerical': 0.003843197540353574, 'mean_word_length': 4.48, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2970069', 'n_tokens_mistral': 876, 'n_tokens_neox': 857, 'n_words': 237}