<commit_before># Author <NAME>
# Fri Mar  6 11:38:37 GMT 2009

import os
import cPickle
import datetime

class IOHelper():
    
    def __init__(self, prefix="./"):
        
        self.ecellManFileName = "ecellManagerObj"
        self.dirRoot = os.path.join(prefix, "Sims")
        
    
    def createSaveDir(self):
        """
            Create the directory where to put the simulation
        """
        today = datetime.date.today()
        free = False
        index = 0
        
        dirDate = today.strftime("%d-%m-%Y")
        
        dirComp = os.path.join(self.dirRoot, dirDate)
        dir = os.path.join(dirComp, "Sim_" + str(index))
        while not free :
            if os.path.exists(dir):
                index = index + 1
                simNum = "Sim_" + str(index)
                dir = os.path.join(dirComp, simNum )
            else:
                free = True
                os.makedirs(dir)
        return dir
    
    def saveObj(self, ecellManager, name):
        
        """ Save results of the simulation. only the logger"""
        dir = self.createSaveDir()
        filepath = os.path.join (dir, name)
        FILE = open(filepath, 'w')
        cPickle.dump(ecellManager, FILE, 1)
        FILE.close()
        print "Python object saved in %s" %os.path.abspath(filepath)
        return dir
    
    def loadObj(self, filename):
        
        """Load the ecellManager into memory"""
        
        FILE = open(filename, 'r')
        obj = cPickle.load(FILE)
        FILE.close()
        print "loaded file %s" %os.path.abspath(filename)
        return obj
    
if __name__ == "__main__":
    
    a= [1,2,3]
    print "Test saving a list obj: %s" %a
    ioH= IOHelper()
    dir = ioH.saveObj(a, "list")
    loaded = ioH.loadObj(dir)
    print "Loaded Obj: %s" %loaded
    print "Is the same object? %s" %(a == loaded)<commit_msg>Changed the name of the variable to one more generic and meaningfull<commit_after># Author <NAME>
# Fri Mar  6 11:38:37 GMT 2009

import os
import cPickle
import datetime
import numpy

class IOHelper():
    
    def __init__(self, prefix="./"):
        
        self.ecellManFileName = "ecellManagerObj"
        self.dirRoot = os.path.join(prefix, "Sims")
        
    
    def createSaveDir(self):
        """
            Create the directory where to put the simulation
        """
        today = datetime.date.today()
        free = False
        index = 0
        
        dirDate = today.strftime("%d-%m-%Y")
        
        dirComp = os.path.join(self.dirRoot, dirDate)
        dir = os.path.join(dirComp, "Sim_" + str(index))
        while not free :
            if os.path.exists(dir):
                index = index + 1
                simNum = "Sim_" + str(index)
                dir = os.path.join(dirComp, simNum )
            else:
                free = True
                os.makedirs(dir)
        return dir
    
    def saveObj(self, obj, name):
        
        """ Save results of the simulation. only the logger"""
        dir = self.createSaveDir()
        filepath = os.path.join (dir, name)
        FILE = open(filepath, 'w')
        cPickle.dump(obj, FILE, 1)
        FILE.close()
        print "Python object saved in %s" %os.path.abspath(filepath)
        return dir
    
    def loadObj(self, filename):
        
        """Load the ecellManager into memory"""
        
        FILE = open(filename, 'r')
        obj = cPickle.load(FILE)
        FILE.close()
        print "loaded file %s" %os.path.abspath(filename)
        return obj
    
    def convertToNumpy(self, vecDict):
        """Convert a dictionary of Hoc Vectors into one of Numpy Vecs"""
        vecsNu = {}
        for k,v in vecDict.iteritems():
            vecsNu[k] = numpy.array(v)
        return vecsNu
    
if __name__ == "__main__":
    
    a= [1,2,3]
    print "Test saving a list obj: %s" %a
    ioH= IOHelper()
    dir = ioH.saveObj(a, "list")
    loaded = ioH.loadObj(dir)
    print "Loaded Obj: %s" %loaded
    print "Is the same object? %s" %(a == loaded)
{'fraction_non_alphanumeric': 0.11584158415841585, 'fraction_numerical': 0.008415841584158416, 'mean_word_length': 1.7546012269938651, 'pattern_counts': {'":': 2, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4705045', 'n_tokens_mistral': 1307, 'n_tokens_neox': 1262, 'n_words': 351}