<commit_before>import unittest
from pprint import pprint
from topo import plot
from topo.sheet import *
from topo.bitmap import RGBMap
from topo.image import ImageGenerator
from topo.inputsheet import *
import Numeric, random, os
from math import pi
from topo.kernelfactory import FuzzyLineFactory
import topo.base
import topo.cfsom
import topo.cfsheet
from topo.plotfilesaver import *
from PIL import *

class TestPlotFileSaver(unittest.TestCase):

    def test_file_saving(self):
        InputSheet.period = 1.0
        InputSheet.density = 400
        FuzzyLineFactory.x = Dynamic(lambda : random.uniform(-0.5,0.5))
        FuzzyLineFactory.y = Dynamic(lambda : random.uniform(-0.5,0.5))
        FuzzyLineFactory.theta = Dynamic(lambda :random.uniform(-pi,pi))
        FuzzyLineFactory.width = 0.02
        FuzzyLineFactory.bounds = BoundingBox(points=((-0.8,-0.8),(0.8,0.8)))
        topo.cfsom.CFSOM.density = 100
        topo.cfsom.CFSOM.learning_length = 10000
        topo.cfsom.CFSOM.radius_0 = 0.1
        topo.cfsheet.KernelProjection.weights_factory = UniformRandomFactory(bounds=BoundingBox(points=((-0.1,-0.1),(0.1,0.1))))
        
        topo.base.min_print_level = topo.base.WARNING
        self.s = topo.simulator.Simulator()
        
        retina = InputSheet(input_generator=FuzzyLineFactory(),name='Retina')
        retina2 = InputSheet(input_generator=FuzzyLineFactory(),name='Retina2')
        V1 = topo.cfsom.CFSOM(name='V1')
        V2 = topo.cfsom.CFSOM(name='V2')
        retina.print_level = topo.base.WARNING
        retina2.print_level = topo.base.WARNING
        V1.print_level = topo.base.WARNING
        V2.print_level = topo.base.WARNING
        
        self.s.connect(retina,V1,delay=0.5,projection_params={'name':'R1toV1'})
        self.s.connect(retina,V2,delay=0.5,projection_params={'name':'R1toV2'})
        self.s.connect(retina2,V2,delay=0.5,projection_params={'name':'R2toV2'})
        self.pe = topo.plotengine.PlotEngine(self.s)
        self.s.run(2)

        af = ActivationFile('Retina')
        wf = WeightsFile('V1',0.0,0.0)
        waf = WeightsArrayFile('V1','R1toV1',10)
#        for each in af.files + wf.files + waf.files:
#            os.remove(each)
#


suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPlotFileSaver))
<commit_msg>Forgot to uncomment the file-deletion loop.<commit_after>import unittest
from pprint import pprint
from topo import plot
from topo.sheet import *
from topo.bitmap import RGBMap
from topo.image import ImageGenerator
from topo.inputsheet import *
import Numeric, random, os
from math import pi
from topo.kernelfactory import FuzzyLineFactory
import topo.base
import topo.cfsom
import topo.cfsheet
from topo.plotfilesaver import *
from PIL import *

class TestPlotFileSaver(unittest.TestCase):

    def test_file_saving(self):
        InputSheet.period = 1.0
        InputSheet.density = 400
        FuzzyLineFactory.x = Dynamic(lambda : random.uniform(-0.5,0.5))
        FuzzyLineFactory.y = Dynamic(lambda : random.uniform(-0.5,0.5))
        FuzzyLineFactory.theta = Dynamic(lambda :random.uniform(-pi,pi))
        FuzzyLineFactory.width = 0.02
        FuzzyLineFactory.bounds = BoundingBox(points=((-0.8,-0.8),(0.8,0.8)))
        topo.cfsom.CFSOM.density = 100
        topo.cfsom.CFSOM.learning_length = 10000
        topo.cfsom.CFSOM.radius_0 = 0.1
        topo.cfsheet.KernelProjection.weights_factory = UniformRandomFactory(bounds=BoundingBox(points=((-0.1,-0.1),(0.1,0.1))))
        
        topo.base.min_print_level = topo.base.WARNING
        self.s = topo.simulator.Simulator()
        
        retina = InputSheet(input_generator=FuzzyLineFactory(),name='Retina')
        retina2 = InputSheet(input_generator=FuzzyLineFactory(),name='Retina2')
        V1 = topo.cfsom.CFSOM(name='V1')
        V2 = topo.cfsom.CFSOM(name='V2')
        retina.print_level = topo.base.WARNING
        retina2.print_level = topo.base.WARNING
        V1.print_level = topo.base.WARNING
        V2.print_level = topo.base.WARNING
        
        self.s.connect(retina,V1,delay=0.5,projection_params={'name':'R1toV1'})
        self.s.connect(retina,V2,delay=0.5,projection_params={'name':'R1toV2'})
        self.s.connect(retina2,V2,delay=0.5,projection_params={'name':'R2toV2'})
        self.pe = topo.plotengine.PlotEngine(self.s)
        self.s.run(2)

        af = ActivationFile('Retina')
        wf = WeightsFile('V1',0.0,0.0)
        waf = WeightsArrayFile('V1','R1toV1',10)
        for each in af.files + wf.files + waf.files:
            os.remove(each)



suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPlotFileSaver))

{'fraction_non_alphanumeric': 0.1269123033828916, 'fraction_numerical': 0.03404438698556345, 'mean_word_length': 3.243144424131627, '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': '1751727', 'n_tokens_mistral': 1726, 'n_tokens_neox': 1638, 'n_words': 243}