made it so that we can calculate truthiness

This commit is contained in:
Stephen McQuay 2011-05-27 17:18:44 -06:00
parent b1626060cf
commit 560fd9a0a5
3 changed files with 28 additions and 7 deletions

View File

@ -5,6 +5,8 @@ indexes = {
2: {
'order' : 0,
'ep' : 1,
'qlin' : 4,
'err' : 5,
'final' : 6,
'exact' : 7,
'time' : 8,
@ -12,6 +14,8 @@ indexes = {
3: {
'order' : 0,
'ep' : 1,
'qlin' : 5,
'err' : 6,
'final' : 7,
'exact' : 8,
'time' : 9,
@ -33,10 +37,12 @@ if __name__ == '__main__':
resolution = int(cur_filename.split('.')[1])
lines = np.loadtxt(cur_filename)
for line in lines:
print "%d %d %d %e %e %e" % (
print "%d %d %d %e %e %e %e %e" % (
resolution,
line[indexes[dim]['order']],
line[indexes[dim]['ep' ]],
line[indexes[dim]['qlin' ]],
line[indexes[dim]['err' ]],
line[indexes[dim]['final']],
line[indexes[dim]['exact']],
line[indexes[dim]['time' ]],

View File

@ -19,8 +19,8 @@ if __name__ == '__main__':
con = sqlite3.connect(sql_file_name)
cur = con.cursor()
cur.execute('DROP TABLE IF EXISTS results')
cur.execute('CREATE TABLE results (res INTEGER, ord INTEGER, ep INTEGER, final FLOAT, exact FLOAT, time FLOAT)')
cur.executemany("insert into results values(?,?,?,?,?,?)", data)
cur.execute('CREATE TABLE results (res INTEGER, ord INTEGER, ep INTEGER, qlin FLOAT, err FLOAT, final FLOAT, exact FLOAT, time FLOAT)')
cur.executemany("insert into results values(?,?,?,?,?,?,?,?)", data)
con.commit()
cur.close()
con.close()

View File

@ -2,7 +2,7 @@ import sys
import os
import sqlite3
from interp.tools import rms
from interp.tools import rms, improved
import numpy as np
@ -19,9 +19,9 @@ if __name__ == '__main__':
action="store_true", dest="time", default=False,
help="write out timing results (default: %default)")
parser.add_option("-T", "--time-by-res",
action="store_true", dest="time", default=False,
help="write out timing (default: %default)")
parser.add_option("-T", "--truthy",
action="store_true", dest="truthy", default=False,
help="calculate truthiness plots (default: %default)")
parser.add_option("-r", "--rms",
action="store_true", dest="rms", default=False,
@ -67,3 +67,18 @@ if __name__ == '__main__':
print "%e " % (cur_time,),
print
if options.truthy:
for ep in extrapoints:
print "%d " % (ep,),
for order in orders:
for res in resolutions:
cur_results = cur.execute('select qlin, err, final, exact from results where res = ? and ep = ? and ord = ?',
(int(res), int(ep),int(order)))
cur_array = np.array(cur.fetchall())
tf = [improved(*i) for i in cur_array]
win_percent = float(tf.count(True)) / len(tf)
print "%e " % (win_percent,),
print