Exemplo n.º 1
0
def main():
	run = True
	while run:
		print('\nSorting algoritm tester')
		choice = userInput()
		
		# run test function with chosen allgorithms
		# takes list size, times of repeat and choosen algorithms and *args
		test(choice['size'], choice['times'], choice['alg'])

		cont = input('Would you like to take another test? y/n ')
		while cont != 'y' and cont != 'n':
			cont = input('Wrong input, run? y/n ')
		if cont == 'n': break
Exemplo n.º 2
0
def main(param):
    # 设置GPU仅需要时申请显存空间
    gpus = tf.config.experimental.list_physical_devices('GPU')
    for gpu in gpus:
        tf.config.experimental.set_memory_growth(gpu, True)
    # 解析命令行参数
    mode = None
    argv = sys.argv[1:]
    try:
        opts, args = getopt.getopt(argv, "m:")  # 短选项模式
    except Exception as err:
        print("Error:", err)

    for opt, arg in opts:
        if opt in ['-m']:
            mode = arg
    # 执行训练或测试
    if mode == 'test':
        test(param)
    else:
        train(param)
Exemplo n.º 3
0
from tests.test import test
from is_prime import is_prime

test(is_prime, [7], True)
test(is_prime, [2], True)
test(is_prime, [6], False)
test(is_prime, [47], True)
test(is_prime, [46], False)
test(is_prime, [89], True)
test(is_prime, [97], True)
test(is_prime, [16], False)
Exemplo n.º 4
0
    def to_post_opHook(self, oNode, sType):
        self.to_post_exprHook(oNode, sType)
        oNode["postfix"][-1]["expr"]["op"] = oNode["op"]
        del oNode['op']
        return True

    def sizeofHook(self, oNode):
        if "primary_id" in oNode\
                and oNode["primary_id"] == "sizeof":
            oExpr = oNode["postfix"][0]["expr"]
            oNode.clear()
            self.__type(oNode, "sizeof")
            oNode["expr"] = oExpr
        return True

    def captured_somethingHook(self, oNode):
        # FIXME : workaround degueu car dans certains cas
        #	    la grammaire d'expression capture .. du vide
        bRes = len(oNode['captured']) > 0
        del oNode['captured']
        return bRes

if __name__ != '__main__':
    CExpression()
else:
    from tests.test import test
    from tests.expression import lTest

    test(lTest, CExpression(), 'test_expression.tpl', 'expression')
    print "All test passed."
Exemplo n.º 5
0
 def test_nan(self):
     from tests.nantest import test
     self.assertTrue(test())
Exemplo n.º 6
0
 def test(self):
     from tests.test import test
     self.assertTrue(test(10))
Exemplo n.º 7
0
 def test_vector(self):
     from tests.vectortest import test
     self.assertTrue(test(10))
from tests.test import test
from is_palindrome import is_palindrome

test( is_palindrome, ['zakaz'], True )
test( is_palindrome, ['madam'], True )
test( is_palindrome, ['do geese see god'], True )
test( is_palindrome, ['i like bananas'], False )
test( is_palindrome, ['malayalam'], True )
from tests.test import test
from is_anagram import is_anagram

test(is_anagram, ["żółw", "włóż"], True)
test(is_anagram, ["abcde", "ebcda"], True)
test(is_anagram, ["magda", "gada"], False)
test(is_anagram, ["listen", "silent"], True)
Exemplo n.º 10
0
from tests.test import test

if __name__ == '__main__':
    test()
Exemplo n.º 11
0
from tests.test import test
from fibonacci import generate

test(generate, [5], [1, 1, 2, 3, 5])
test(generate, [10], [1, 1, 2, 3, 5, 8, 13, 21, 34, 55])
test(generate, [12], [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144])
Exemplo n.º 12
0
        elif 'array' not in oNode\
            and 'body' not in oNode\
            and oNode["ctype"]["type"] not in\
                ["__union__", "__enum__", "__struct__"]:
            self.typeHook(oNode, "__prototype__")
            if "return" in oNode["ctype"]:
                oNode["ctype"].update(oNode["ctype"]["return"])
                del oNode["ctype"]["return"]
        if oNode["ctype"]["type"] == "declaration_specifiers":
            self.ctypeHook(oNode, "__variable__")
        return True

    def isHook(self, oNode, sType, sSubKey=None):
        if sSubKey != None:
            oNode = oNode[sSubKey]
        print oNode['type']
        return oNode['type'] == sType


if __name__ != '__main__':
    CDeclaration()
else:
    from tests.test import test
    from tests.declaration import lTest

    bRes = test(lTest, CDeclaration(), 'declaration.tpl', 'translation_unit')
    if bRes == False:
        print "All test passed."
    else:
        print "Some exceptions were raised in the hooks."
Exemplo n.º 13
0
from tests.test import test
from bubblesort import bubblesort as sort

test(sort, [[1, 2, 6, 3, 2, 5]], [1, 2, 2, 3, 5, 6])
test(sort, [[20, 32, 12, 69, 17, 1, -10]], [-10, 1, 12, 17, 20, 32, 69])
test(sort, [[6, 7, 8, 1, 2, 3, 1, 2, 3, 10]], [1, 1, 2, 2, 3, 3, 6, 7, 8, 10])
Exemplo n.º 14
0
'''
Created on Dec 18, 2018
@author: Marius
'''
from persistance.repository import repository
from tests.test import test
from validators.validators import validator
from bussines.service import service
from UI.console import console

valid = validator()
repo = repository("Students.txt")
servStudent = service(valid, repo)

c = console(servStudent)
t = test()

#t.run()
c.run()
Exemplo n.º 15
0
from pyrser.grammar import Grammar
from pyrser.hooks import GenericHook
from expression import CExpression


class CStatement(GenericHook, Grammar):
    def __init__(self):
        GenericHook.__init__(self)
        Grammar.__init__(self, CStatement,
                         open("./grammar/statement.pw").read(),
                         globals())

    def typeHook(self, oNode, sSubExpr, sType="__statement__"):
        """
        Type should attribute an automatic name: per grammar function.
        """
        oNode["type"] = sType
        oNode["sub_type"] = sSubExpr
        return oNode

if __name__ != '__main__':
    CStatement()
else:
    from tests.test import test
    from tests.statement import lTest

    test(lTest, CStatement(), 'test_statement.tpl', 'statement')
    print "All test passed."
Exemplo n.º 16
0
from tests.test import test
from search_customer import search

correct_1 = [
    "Gasai\tYuno\t(+81)120-389-123", "Amano\tYukiteru\t(+81)783-124-632"
]
test(search, ["customers", "Yu"], correct_1)

correct_2 = [
    "Gasai\tYuno\t(+81)120-389-123", "Deus\tExMachina\t(+81)777-666-120"
]
test(search, ["customers", "120"], correct_2)

correct_3 = []
test(search, ["customers", "Carrot"], correct_3)