本文整理汇总了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)
示例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())
示例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
示例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)
示例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];
示例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()
示例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))
示例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)
示例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)
示例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)
示例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))
示例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
示例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")
示例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))
示例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