当前位置: 首页>>代码示例>>Python>>正文


Python test.test函数代码示例

本文整理汇总了Python中test.test函数的典型用法代码示例。如果您正苦于以下问题:Python test函数的具体用法?Python test怎么用?Python test使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了test函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test

def test():
    import test

    pygame.init()
    tb = TextBox(text="Fishy")
    clock = pygame.time.Clock()
    group = pygame.sprite.LayeredDirty(tb, layer=0, _use_update=True)

    def testlogic(event):
        if event == None:
            return
        if event.type == pygame.KEYDOWN:
            if event.key == 27:
                return True
            if event.key == K_BACKSPACE:
                if len(tb.text) > 0:
                    tb.text = tb.text[:-1]
                return
            if event.key >= 256:
                return
            tb.text += chr(event.key)

    def testrender(screen):
        clock.tick()
        time = clock.get_time()
        group.update(time)
        bgd = pygame.Surface((screen.get_width(), screen.get_height()))
        group.draw(screen, bgd=bgd)

    test.test(testlogic, testrender)
开发者ID:wilminator,项目名称:pysprite,代码行数:30,代码来源:TextBox.py

示例2: main

def main():
    print "In Main Experiment\n"
    # get the classnames from the directory structure
    directory_names = list(set(glob.glob(os.path.join("train", "*"))).difference(set(glob.glob(os.path.join("train", "*.*")))))
    # get the number of rows through image count
    numberofImages = parseImage.gestNumberofImages(directory_names)
    num_rows = numberofImages # one row for each image in the training dataset

    # We'll rescale the images to be 25x25
    maxPixel = 25
    imageSize = maxPixel * maxPixel
    num_features = imageSize + 2 + 128 # for our ratio

    X = np.zeros((num_rows, num_features), dtype=float)
    y = np.zeros((num_rows)) # numeric class label
    files = []
    namesClasses = list() #class name list

    # Get the image training data
    parseImage.readImage(True, namesClasses, directory_names,X, y, files)

    print "Training"

    # get test result
    train.train(X, y, namesClasses)

    print "Testing"
    test.test(num_rows, num_features, X, y, namesClasses = list())
开发者ID:LvYe-Go,项目名称:Foreign-Exchange,代码行数:28,代码来源:main.py

示例3: startSouth

def startSouth(below, ordered = []):
    "Sort Southern cities into order"
    jyunban = sortx(below, 'ascending')             #Decide starting city
    minami = len(jyunban)
    ordered.append(jyunban[0])
    jyunban.pop(0)
    
    alldistance = getdistances(ordered[0], jyunban) #Decide last southern city
    index = alldistance.index(max(alldistance))
    furthest = jyunban[index]
    jyunban.pop(index)
    
    while len(ordered) < minami/2:                  #Route from start point
        decidenext(jyunban, ordered, 'south')
        test(ordered)
    
    second =  sortx(jyunban, 'descending')          #Route from end point
    lensecond = len(second)
    gyaku = []
    gyaku.append(furthest)
    while len(gyaku) < lensecond+1:
        decidenext(second, gyaku, 'north')
    
    for i in range(1,len(gyaku)+1):                 #Put two routes together
        ordered.append(gyaku[-i])
    
    #checkintercept(ordered)
    return ordered
开发者ID:msaitoo,项目名称:STEPhw6,代码行数:28,代码来源:new_solver.py

示例4: run

def run(train_file, valid_file, test_file, output_file):
    '''The function to run your ML algorithm on given datasets, generate the output and save them into the provided file path

    Parameters
    ----------
    train_file: string
        the path to the training file
        valid_file: string
                the path to the validation file
        test_file: string
                the path to the testing file
    output_file: string
        the path to the output predictions to be saved
    '''

    ## your implementation here

    # read data from input
    train_samples, word2num = train_data_prepare(train_file)
    valid_samples = test_data_prepare(valid_file, word2num, 'valid')

    # your training algorithm
    model = train(train_samples, valid_samples, word2num)

    # your prediction code
    test(test_file, output_file, word2num, model)
开发者ID:randidwiputra,项目名称:fake-news-detection,代码行数:26,代码来源:run.py

示例5: main

def main (argv):
    logger = initLogger();
    
    if (len(argv) == 0):
        print "Missing argument. Options: init, store, list, test, get, restore";
    elif (argv[0] == "init"):
        init.init(archiveDir);
    elif (argv[0] == "store"):
        if (len(argv) < 2):
            print "Usage: mybackup store <directory>";
        else:
            store.store(archiveDir, argv[1], logger);
    elif (argv[0] == "list"):
        if (len(argv) < 2):
            listBackups.list(archiveDir)
        else:
            listBackups.list(archiveDir, argv[1])
    elif (argv[0] == "get"):
        if (len(argv) < 2):
            print "Usage: mybackup get <pattern>";
        else:
            restore.getFile(archiveDir, argv[1]);
    elif (argv[0] == "restore"):
        if (len(argv) < 2):
            restore.restoreAll(archiveDir)
        else:
            restore.restoreAll(archiveDir, argv[1])
    elif (argv[0] == "test"):
        test.test(archiveDir, logger)
    else:
        print "Unknown option: "+argv[0];
开发者ID:BakedAs,项目名称:Assignment251,代码行数:31,代码来源:mybackup.py

示例6: cli_main

def cli_main():
	if sys.version_info[0] < 3:
		print("STK needs Python 3.x to run. Check your execution path and file associations.")
		print("Your Python version is: ")
		print(sys.version)
		return

	if len(sys.argv) >= 2:
		if sys.argv[1] == "--test":
			import test
			test.test(sys.argv[2:])

		elif sys.argv[1] == "--markdown2html" and len(sys.argv) == 4:

			input_file = sys.argv[2]
			output_dir = sys.argv[3]

			parser = MDParser()
			parser.parse_file(input_file)

			exporter = HtmlExporter()
			exporter.export(parser.saga, output_dir)

		elif sys.argv[1] == "--generate_ep_card" and len(sys.argv) == 4:
			#generate_episode_card(sys.argv[2], sys.argv[3])
			#TODO generate_episode_card
			print("Not implemented yet...")

		else:
			print_usage()
	else:
		print_usage()
开发者ID:Zylann,项目名称:SagaToolkit,代码行数:32,代码来源:stk.py

示例7: test3

def test3():
   cost = [1,1,1]
   eqs = [[1,1,0], [2,2,2]]
   eqB = [2, 5]

   expectedCost = [1,1,1]
   expectedConstraints = [[3,-2,0], [1,1,0]]
   expectedThresholds = [2, 5]
   test((expectedCost, expectedConstraints, expectedThresholds),
         simplex.standardForm(cost, equalities=eqs, eqThreshold=eqB))
开发者ID:Eyrone,项目名称:simplex-algorithm,代码行数:10,代码来源:standard-form-test.py

示例8: mainHandler

def mainHandler(threadNum, link, deep, key, test):
    event = threading.Event()  # 产生一个event对象,对象维护一个flag,当
    event.clear()  # 将event的flag设为false
    pool = threadPool(threadNum, event)  # 初始化一个threadNum个线程的线程池,event对象用于通知主线程继续执行
    showProgress(pool.getQueue(), deep, event)
    pool.putJob((link, deep), key)  # job是(link,deep)的一个tuple,key是关键字
    pool.wait()  # 阻塞主线程
    if test:  # 需要自测模块运行
        import test
        test.test(key, dbFile)
开发者ID:silentsee,项目名称:knowsecSpider2,代码行数:10,代码来源:spider.py

示例9: mainHandler

def mainHandler(threadNum, link, deep, key, test):
    event = threading.Event()
    event.clear()
    pool = threadPool(threadNum, event)
    showProgress(pool.getQueue(), deep, event)
    pool.putJob((link, deep), key)
    pool.wait()
    if test:  # 需要自测模块运行
        import test
        test.test(key, dbFile)
开发者ID:0x554simon,项目名称:knowsecSpider2,代码行数:10,代码来源:spider.py

示例10: test

def test():
    import test
    pygame.init()
    image = pygame.image.load("qbird.png")
    sprite = ManipulatableDirtySprite(image = image)
    clock = pygame.time.Clock()
    group = pygame.sprite.LayeredDirty(sprite, layer = 0, _use_update = True)
    keysused = {}
    def testlogic(event):
        if event == None:            
            time = clock.get_time()
            if K_UP in keysused and keysused[K_UP]:
                sprite.y -= 1
            if K_DOWN in keysused and keysused[K_DOWN]:
                sprite.y += 1
            if K_LEFT in keysused and keysused[K_LEFT]:
                sprite.x -= 1
            if K_RIGHT in keysused and keysused[K_RIGHT]:
                sprite.x += 1
            if K_q in keysused and keysused[K_q]:
                sprite.rotation -= 1
            if K_e in keysused and keysused[K_e]:
                sprite.rotation += 1
            if K_w in keysused and keysused[K_w]:
                sprite.ycenter -= 0.015625
            if K_s in keysused and keysused[K_s]:
                sprite.ycenter += 0.015625
            if K_a in keysused and keysused[K_a]:
                sprite.xcenter -= 0.015625
            if K_d in keysused and keysused[K_d]:
                sprite.xcenter += 0.015625
            if K_r in keysused and keysused[K_r]:
                sprite.yscale += 0.015625
            if K_f in keysused and keysused[K_f]:
                sprite.yscale -= 0.015625
            if K_t in keysused and keysused[K_t]:
                sprite.xscale += 0.015625
            if K_g in keysused and keysused[K_g]:
                sprite.xscale -= 0.015625
            if K_y in keysused and keysused[K_y]:
                sprite.opacity += 0.015625
            if K_h in keysused and keysused[K_h]:
                sprite.opacity -= 0.015625
            return
        if event.type == pygame.KEYDOWN:
            if event.key == 27:
                return True
            keysused[event.key] = True
        if event.type == pygame.KEYUP:
            keysused[event.key] = False
    def testrender(screen):
        clock.tick()
        bgd = pygame.Surface((screen.get_width(), screen.get_height()))
        group.draw(screen, bgd = bgd)
    test.test(testlogic, testrender)
开发者ID:wilminator,项目名称:pysprite,代码行数:55,代码来源:ManipulatableDirtySprite.py

示例11: test2

def test2():
   cost = [1,1,1]
   lts = [[3,-2,0]]
   ltB = [7]
   eqs = [[1,1,0]]
   eqB = [2]

   expectedCost = [1,1,1,0]
   expectedConstraints = [[3,-2,0,1], [1,1,0,0]]
   expectedThresholds = [7,2]
   test((expectedCost, expectedConstraints, expectedThresholds),
         simplex.standardForm(cost, lessThans=lts, ltThreshold=ltB, equalities=eqs, eqThreshold=eqB))
开发者ID:Eyrone,项目名称:simplex-algorithm,代码行数:12,代码来源:standard-form-test.py

示例12: evalQuiz

def evalQuiz(user, data):
    f = open(join(quiz_requests, '%s.quiz-%s.%d' % 
                  (user, data['page'].split('-')[-1], 
                   int(time() * 1000))), 'w')
    f.write(str(data))
    f.close()

    path.insert(0, join(course_material, str(data['page'])))
    #test_mod = __import__(join(course_material, str(data['page']), 'test.py'))
    import test as test_mod
    test_mod.test(user, data)

    del test_mod
开发者ID:darrenkuo,项目名称:SICP,代码行数:13,代码来源:quiz.py

示例13: trainrf

def trainrf(model_id,train_x,train_y,valid_x,valid_y,test_x):
    train_x,train_y=shuffle(train_x,train_y)


    random_state=random.randint(0, 1000000)
    print('random state: {state}'.format(state=random_state))

    clf = RandomForestClassifier(n_estimators=random.randint(50,5000),
                                 criterion='gini',
                                 max_depth=random.randint(10,1000),
                                 min_samples_split=random.randint(2,50),
                                 min_samples_leaf=random.randint(1,10),
                                 min_weight_fraction_leaf=random.uniform(0.0,0.5),
                                 max_features=random.uniform(0.1,1.0),
                                 max_leaf_nodes=random.randint(1,10),
                                 bootstrap=False,
                                 oob_score=False,
                                 n_jobs=30,
                                 random_state=random_state,
                                 verbose=0,
                                 warm_start=True,
                                 class_weight=None
                )

    clf.fit(train_x, train_y)

    valid_predictions1 = clf.predict_proba(valid_x)
    test_predictions1= clf.predict_proba(test_x)

    t1 = test(valid_y,valid_predictions1)

    ccv = CalibratedClassifierCV(base_estimator=clf,method="sigmoid",cv='prefit')
    ccv.fit(valid_x,valid_y)

    valid_predictions2 = ccv.predict_proba(valid_x)
    test_predictions2= ccv.predict_proba(test_x)

    t2 = test(valid_y,valid_predictions2)

    if t2<t1:
        valid_predictions=valid_predictions2
        test_predictions=test_predictions2
        t=t2
    else:
        valid_predictions=valid_predictions1
        test_predictions=test_predictions1
        t=t1

    if t < 0.450:
        data.saveData(valid_predictions,"../valid_results/valid_"+str(model_id)+".csv")
        data.saveData(test_predictions,"../results/results_"+str(model_id)+".csv")
开发者ID:hujiewang,项目名称:otto,代码行数:51,代码来源:com.py

示例14: testFromPost

def testFromPost():
   cost = [1,1,1]
   gts = [[0,1,4]]
   gtB = [10]
   lts = [[3,-2,0]]
   ltB = [7]
   eqs = [[1,1,0]]
   eqB = [2]

   expectedCost = [1,1,1,0,0]
   expectedConstraints = [[0,1,4,-1,0], [3,-2,0,0,1], [1,1,0,0,0]]
   expectedThresholds = [10,7,2]
   test((expectedCost, expectedConstraints, expectedThresholds),
         simplex.standardForm(cost, gts, gtB, lts, ltB, eqs, eqB))
开发者ID:Eyrone,项目名称:simplex-algorithm,代码行数:14,代码来源:standard-form-test.py

示例15: cal

def cal(code):
	try:
		a=gc.getData(code)
	except:
		print('{} is wrong'.format(code))	
	else:	
		print('{} is running'.format(code))
		if a is not None and len(a)>60:
			global total
			total=total+1
			a.sort_index(inplace=True)
			gc.ma(a,'close',[5,10,15,20,25])
			MA_column=a.columns[-5:]
			a['Diff']= 100 * ((a[MA_column].max(axis=1) - a[MA_column].min(axis=1))/a[MA_column].max(axis=1))
			b=a[-65:-5]['Diff'].mean()
			if b<2 and a[-65:-5]['Diff'].max()<10:
				good.append(code)
				global can_try
				can_try=can_try+1
				# print('{},{}'.format(a[-2:-1].index.values[0],a[-1:].index.values[0]))
				diff=test.test(code,a[-6:-5].index.values[0],a[-1:].index.values[0])
				diff_list.append(diff)
				if diff>0:
					global test_try
					test_try=test_try+1	
开发者ID:taotaocoule,项目名称:stock,代码行数:25,代码来源:main.py


注:本文中的test.test函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。