Commit 7dc1c609 authored by Oliver Schmidts's avatar Oliver Schmidts

mac compability and refactored tests

parent bc609699
#!/usr/bin/env python
import os
import sys
from sys import *
sys.path.append(os.path.abspath(os.path.dirname(sys.path[0])))
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) ) )
dy4 = np.sum( np.abs( np.diff(y4) ) )
# evac_time = ( max( traj[:,1] ) - min( traj[:,1] ) ) / float(fps)
tolerance = 0.0001
if dy2 > tolerance or dy4 >tolerance:
logging.info("%s exits with FAILURE dy2 = %f, dy4 = %f"%(argv[0], dy2, dy4))
exit(FAILURE)
else:
logging.info("%s exits with SUCCESS dy2 = %f dy4 = %f"%(argv[0], dy2, dy4))
if __name__ == "__main__":
test = JPSRunTestDriver(12, argv0=argv[0], testdir=sys.path[0])
test.run_test(testfunction=runtest12)
logging.info("%s exits with SUCCESS" % (argv[0]))
exit(SUCCESS)
#!/usr/bin/env python
import os
import sys
from sys import *
import scipy
import scipy.stats
import matplotlib.pyplot as plt
sys.path.append(os.path.abspath(os.path.dirname(sys.path[0])))
from JPSRunTest import JPSRunTestDriver
from utils import *
__author__ = 'Oliver Schmidts'
def runtest14(inifile, trajfile, PX, PY):
maxtime = get_maxtime(inifile)
fps, N, data = parse_file(trajfile)
data = data[ data[:,1] == 0 ]
x = data[:,2]
y = data[:,3]
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]
PX.append(px)
PY.append(py)
if __name__ == "__main__":
OK = 1
PX = [] #p-value for x
PY = [] #p-value for y
test = JPSRunTestDriver(14, argv0=argv[0], testdir=sys.path[0])
test.run_test(runtest14, PX, PY)
plt.subplot(211)
plt.plot(PX, label="PX")
plt.ylabel("px")
plt.subplot(212)
plt.plot(PY, label="PY")
plt.ylabel("py")
plt.savefig("px_py.png")
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)))
OK = 0
exit(FAILURE)
else:
logging.info("PX = %f PY = %f"%( np.mean(PX), np.mean(PY)))
exit(SUCCESS)
\ No newline at end of file
#!/usr/bin/env python
import os
import sys
from sys import *
import scipy
import scipy.stats
import matplotlib.pyplot as plt
sys.path.append(os.path.abspath(os.path.dirname(sys.path[0])))
from JPSRunTest import JPSRunTestDriver
from utils import *
__author__ = 'Oliver Schmidts'
def runtest15(inifile, trajfile):
logsim = "inifiles/log.P0.dat"
if not 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])
test.run_test(runtest15)
logging.info("%s exits with SUCCESS"%(argv[0]))
exit(SUCCESS)
\ No newline at end of file
......@@ -149,6 +149,6 @@ const optStorage &CognitiveMapRouter::getOptions() const
void CognitiveMapRouter::addOption(const std::string &key, const std::vector<std::string> &value)
{
options.emplace(key,value);
options.insert(std::make_pair(key, value));
}
......@@ -49,7 +49,7 @@ class NavLine;
//c++11 alias: Container to store options for the router (i. a. sensors)
using optStorage = std::unordered_map<std::string,std::vector<std::string>>;
using optStorage = std::unordered_map<std::string,std::vector<std::string> >;
class CognitiveMapRouter: public Router {
public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment