예제 #1
0
    def run(self, scenario):
        """ Running the simulator consists in firing the net and 
        udpating token values according to the given commands 
        Then output data is record in a Scenario
        Return the name of the simulator

        >>> simu = test.simple_simulator()
        """
        s = scenario
        s.read(skiprows=[1])

        ts = s.ts()
        ucs = s.ucs()
        uds = s.uds()

        bar = ProgressBar(ts[-1], 60, 'simu', self.k)
        bar.update(self.k)

        logging.disable(logging.INFO)

        timer = time.time()

        for t, uc, ud in zip(ts, ucs, uds):
            yc, yd = self.update(t, uc, ud, set())

            bar.update(self.k)

        timer = time.time() - timer

        logging.disable(logging.NOTSET)
        print()

        return timer
예제 #2
0
#!/usr/bin/env python2
import imgs
import numpy as np
import os
import random
import scipy.misc
import sys
import unittest
from PIL import Image

BASE_DIR = os.path.abspath(os.path.dirname(__file__))
sys.path.append(os.path.join(BASE_DIR, '..', 'shit'))
import analyse
import log

log.disable()


class AnalyseTest(unittest.TestCase):
    ###########################################################################
    ####################################################### helper functions ##
    ###########################################################################
    def test_open_img(self):
        img = imgs.create_rgb()
        # given an Pillow Image, open_img should return the same instance
        self.assertEqual(id(img), id(analyse.open_img(img)))
        # given an path, open_img should return a Pillow Image instance
        with imgs.TempFile(img) as img_path:
            opened_img = analyse.open_img(img_path)
            self.assertTrue(isinstance(opened_img, Image.Image))
            self.assertEqual(list(img.getdata()), list(opened_img.getdata()))
예제 #3
0
파일: test_all.py 프로젝트: shouh/jpwincron
# -*- coding: utf-8 -*-

import unittest

import test_croncore
import test_log_filewriter

# 一列が長くなるのでエイリアスを導入.
# before: unittest.TestLoader().loadTestsFromTestCase(TestHoge)
# after : loader()(TestHoge)
def loader():
    return unittest.TestLoader().loadTestsFromTestCase
suites = [\
loader()(test_croncore.TestJudge), \
loader()(test_croncore.TestMode), \
loader()(test_log_filewriter.TestLogFileWriter), \
]

testsuites = unittest.TestSuite(suites)
runner = unittest.TextTestRunner()

# ログ出力抑止
import log
log.disable()

runner.run(testsuites)
예제 #4
0
        bar = ProgressBar(ts[-1], 60, 'simu', self.k)
        bar.update(self.k)

        logging.disable(logging.INFO)

        timer = time.time()

        for t, uc, ud in zip(ts, ucs, uds):
            yc, yd = self.update(t, uc, ud, set())

            bar.update(self.k)

        timer = time.time() - timer

        logging.disable(logging.NOTSET)
        print()

        return timer

    def write(self, filename):
        """ Write simulator scenario to given filename
        """
        self.scenario.write(filename)


if __name__ == "__main__":
    import doctest
    import test
    logging.disable(logging.INFO)
    doctest.testmod()
예제 #5
0
 def prognose(self, *args, **kargs):
     logging.disable(logging.INFO)
     self.prog.prognose(*args, **kargs)
     logging.disable(logging.NOTSET)