本文整理汇总了Python中JPSRunTest.JPSRunTestDriver类的典型用法代码示例。如果您正苦于以下问题:Python JPSRunTestDriver类的具体用法?Python JPSRunTestDriver怎么用?Python JPSRunTestDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JPSRunTestDriver类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runtest3
import sys
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
from sys import *
sys.path.append(utestdir)
from JPSRunTest import JPSRunTestDriver
from utils import *
__author__ = 'Oliver Schmidts'
def runtest3(inifile, trajfile):
# x y1 y2
# | | |
# v v v
door= [8.5, 2.0, 3.0] # value from geometry file. Door is at 9.0 m shifted by 0.5 m
maxtime = get_maxtime(inifile)
fps, N, traj = parse_file(trajfile)
evac_time = (max(traj[:, 1]) - min(traj[:, 1])) / float(fps)
if evac_time > maxtime*0.5 or not PassedLineX(traj, door):
logging.info("%s exits with FAILURE. evac_time = %f (maxtime = %f) or not passed exit" % (argv[0], evac_time, maxtime))
exit(FAILURE)
else:
logging.info("evac_time = %f (maxtime = %f)" % (evac_time, maxtime))
if __name__ == "__main__":
test = JPSRunTestDriver(3, argv0=argv[0], testdir=sys.path[0], utestdir=utestdir)
test.run_test(testfunction=runtest3)
logging.info("%s exits with SUCCESS" % (argv[0]))
exit(SUCCESS)
示例2: abs
if abs(mean_cor-mean_stair) < tolerance:
logging.critical("%s exists with FAILURE. Flows are almost equal:", argv[0])
exit(FAILURE)
def run_rimea_test13(inifile, trajfile):
fps, N, traj = parse_file(trajfile)
exit_basement = 0
start_stair = 12
J_corridor = flow(fps, N, traj, exit_basement)
J_stair = flow(fps, N, traj, start_stair)
logging.info("J_corridor = %.2f, J_stair = %.2f (tolerance = %.2f)",
J_corridor, J_stair, tolerance)
return (J_corridor, J_stair)
if __name__ == "__main__":
test = JPSRunTestDriver(13, argv0=argv[0], testdir=sys.path[0], utestdir=utestdir)
results = test.run_test(testfunction=run_rimea_test13)
eval_results(results)
logging.info("%s exits with SUCCESS" % (argv[0]))
exit(SUCCESS)
示例3: run_validation_1
fd_exp = results[0]
fd_sim = results[1]
dexp = results[0]
dsim = results[1]
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
plt.plot(dsim[:, 1], dsim[:, 2], ".b", alpha=0.5, label="simulation")
plt.plot(dexp[:, 0], dexp[:, 1], "xr", label="experiment")
plt.ylabel(r"$v\; [m/s]$", size=ms)
plt.xlabel(r"$\rho \; [1/m]$", size=ms)
plt.ylim([0, 1.5])
plt.xlim([0, 3.0])
plt.xticks(fontsize=mt)
plt.yticks(fontsize=mt)
plt.legend(loc="best", numpoints=1)
fig.set_tight_layout(True)
plt.savefig("fd1d.png", dpi=300)
def run_validation_1(inifile, trajfile):
return 0
if __name__ == "__main__":
test = JPSRunTestDriver(101, argv0=argv[0],
testdir=sys.path[0],
utestdir=utestdir)
results = test.run_test(testfunction=run_validation_1, fd=1)
eval_results(results)
logging.info("%s exits with SUCCESS" % (argv[0]))
exit(SUCCESS)
示例4: run_rimea_test11
sys.path.append(utestdir)
from JPSRunTest import JPSRunTestDriver
from utils import *
def run_rimea_test11(inifile, trajfile):
files = glob.glob("trajectories/*_exit*")
for f in files:
# Read data
data = np.loadtxt(f)
num_evacuated = data[-1, 1]
logging.info("%d peds evacuated from exit <%s>", num_evacuated, f.split(".dat")[0].split("_id_")[1])
if __name__ == "__main__":
test = JPSRunTestDriver(11, argv0=argv[0], testdir=sys.path[0], utestdir=utestdir)
test.run_test(testfunction=run_rimea_test11)
logging.info("%s exits with SUCCESS" % (argv[0]))
exit(SUCCESS)
示例5: return
nx = plt.hist(x, bins=10)[0]
ny = plt.hist(y, bins=10)[0]
px = scipy.stats.chisquare(nx)[1]
py = scipy.stats.chisquare(ny)[1]
return (px, py)
# PX.append(px)
# PY.append(py)
if __name__ == "__main__":
PX = [] #p-value for x
PY = [] #p-value for y
test = JPSRunTestDriver(14, argv0=argv[0], testdir=sys.path[0], utestdir=utestdir)
results = test.run_test(testfunction=runtest14)
results = np.array(results)
PX = results[:, 0]
PY = results[:, 1]
plotit(PX, PY)
if np.mean(PX) < 0.1 or np.mean(PY)< 0.1:
logging.info("%s exits with FAILURE PX = %f PY = %f"%(argv[0], np.mean(PX), np.mean(PY)))
exit(FAILURE)
else:
logging.info("PX = %f PY = %f"%(np.mean(PX), np.mean(PY)))
logging.info("%s exits with SUCCESS"%(argv[0]))
exit(SUCCESS)
示例6: runtest12
import os
import sys
utestdir = os.path.abspath(os.path.dirname(os.path.dirname(sys.path[0])))
from sys import *
sys.path.append(utestdir)
from JPSRunTest import JPSRunTestDriver
from utils import *
__author__ = 'Oliver Schmidts'
def runtest12(inifile, trajfile):
maxtime = get_maxtime(inifile)
fps, N, traj = parse_file(trajfile)
y2 = traj[traj[:, 0] == 2][:, 3]
y4 = traj[traj[:, 0] == 4][:, 3]
dy2 = np.sum(np.abs(np.diff(y2)))
# evac_time = ( max( traj[:,1] ) - min( traj[:,1] ) ) / float(fps)
tolerance = 0.005
if dy2 > tolerance:
logging.info("%s exits with FAILURE dy2 = %f (tolerance=%f)", argv[0], dy2, tolerance)
exit(FAILURE)
else:
logging.info("dy2 = %f (tolerance=%f)", dy2, tolerance)
if __name__ == "__main__":
test = JPSRunTestDriver(12, argv0=argv[0], testdir=sys.path[0], utestdir=utestdir)
test.run_test(testfunction=runtest12)
logging.info("%s exits with SUCCESS" % (argv[0]))
exit(SUCCESS)
示例7: max
plt.plot(num_threads, evac_times, "o-b", alpha=0.5)
plt.ylabel(r"Evacuation Time [s]", size=ms)
plt.xlabel(r"#Threads", size=ms)
plt.xlim([min(num_threads)-0.5, max(num_threads)+0.5])
plt.xticks(fontsize=mt)
plt.xticks(num_threads, fontsize=mt)
plt.title("mean = %f (+-%f) [s]" % (mean, std))
plt.grid(alpha=0.7)
plt.savefig("evactimes.png", dpi=300)
def run_test_9(inifile, trajfile):
maxtime = get_maxtime(inifile)
num_threads = get_num_threads(inifile)
fps, N, traj = parse_file(trajfile)
if not N:
logging.critical(" N = %d"%N)
exit(FAILURE)
evac_time = (max(traj[:, 1]) - min(traj[:, 1])) / float(fps)
return (num_threads, evac_time)
if __name__ == "__main__":
test = JPSRunTestDriver(9, argv0=argv[0],
testdir=sys.path[0],
utestdir=utestdir)
results = test.run_test(testfunction=run_test_9)
eval_results(results)
logging.info("%s exits with SUCCESS" % (argv[0]))
exit(SUCCESS)
示例8: PassedLineX
e2 = [18, 1, 2] # x, y1, y2
logging.info("Checking the exits of pedestrians ...")
for ped in peds:
traj1 = traj[ traj[:,0] == ped ]
x = traj1[:,2]
y = traj1[:,3]
if PassedLineX(traj1, e2):
logging.critical("ped %d exits from Exit (%1.2f, %1.2f) | (%1.2f, %1.2f)"%(ped, e2[0], e2[1], e2[0], e2[2]))
failure = True
if failure:
logging.critical("%s exists with failure!"%argv[0])
exit(FAILURE)
def PassedLineX(p, exit):
"""
check if pedestrian (given by matrix p) passed the vertical line x, [y1, y2] y1<y2
"""
x = exit[0]
y1 = exit[1]
y2 = exit[2]
return any(p[:,2] <= x) & any(p[:,2] >= x) & any(p[:,3] >= y1) & any(p[:,3] <= y2)
if __name__ == "__main__":
test = JPSRunTestDriver(7.1, argv0=argv[0], testdir=sys.path[0], utestdir=utestdir)
test.run_test(testfunction=runtest71)
logging.info("%s exits with SUCCESS" % (argv[0]))
exit(SUCCESS)
示例9: exit
exec_time = -1
evac_time = -2
logsim = "inifiles/log.P0.dat"
if not os.path.exists(logsim):
logging.critical("logsim <%s> does not exist"%logsim)
exit(FAILURE)
logging.info("open <%s> "%logsim)
f = open(logsim, "r")
for line in f:
if line.startswith("Exec"):
exec_time = float(line.split()[-1])
if line.startswith("Evac"):
evac_time = float(line.split()[-1])
f.close()
# if evac_time < exec_time:
# logging.info("%s exits with FAILURE evac_time = %f, exec_time = %f)"%
# (argv[0], evac_time, exec_time))
# exit(FAILURE)
# else:
logging.info("evac_time = %f exec_time = %f)"%(evac_time, exec_time))
if __name__ == "__main__":
test = JPSRunTestDriver(15, argv0=argv[0], testdir=sys.path[0], utestdir=utestdir)
test.run_test(runtest15)
logging.info("%s exits with SUCCESS"%(argv[0]))
exit(SUCCESS)