made the 'connectivity' tests work (whatever they were)

This commit is contained in:
Stephen McQuay 2011-03-24 15:48:36 -06:00
parent e8414417a5
commit 928a4ccdab
4 changed files with 29 additions and 28 deletions

View File

@ -1,11 +1,14 @@
#!/usr/bin/env python
import sys
from grid.DD import random_grid
from baker import get_phis, run_baker
from baker.tools import exact_func, smberror, improved_answer, smblog
import os
import pickle
from glob import glob
from os import remove
from interp.grid.DD import random_grid
from interp.baker import get_phis, run_baker
from interp.tools import friendly_exact_2D as exact_func, improved_answer
import numpy as np
@ -19,14 +22,14 @@ def draw_gb(bad, good):
pylab.plot(good)
pylab.legend(('bad', 'good'))
pylab.show()
pylab.savefig("output.png")
FILE_PREFIX='/tmp/qhull-'
if __name__ == '__main__':
for g in glob('%s*' % FILE_PREFIX):
remove(g)
os.remove(g)
try:
total_points = int(sys.argv[1])
@ -37,10 +40,6 @@ if __name__ == '__main__':
sys.exit(1)
smblog.debug("total points: %d" % total_points)
d = {True: 0, False: 0}
good = []
bad = []
@ -67,3 +66,4 @@ if __name__ == '__main__':
good.append(d[True])
draw_gb(bad = bad, good = good)
pickle.dump((bad,good), open("test.p", 'w'))

View File

@ -1,11 +1,14 @@
#!/usr/bin/env python
import sys
from interp.grid.DDD import random_grid
from interp.baker import get_phis, run_baker
from interp.tools import exact_func, improved_answer, log
import os
import pickle
from glob import glob
from os import remove
from interp.grid.DDD import random_grid
from interp.baker import get_phis, run_baker
from interp.tools import baker_exact_3D as exact_func, improved_answer
import numpy as np
@ -19,14 +22,14 @@ def draw_gb(bad, good):
pylab.plot(good)
pylab.legend(('bad', 'good'))
pylab.show()
pylab.savefig("output.png")
FILE_PREFIX='/tmp/qhull-'
if __name__ == '__main__':
for g in glob('%s*' % FILE_PREFIX):
remove(g)
os.remove(g)
try:
total_points = int(sys.argv[1])
@ -39,11 +42,11 @@ if __name__ == '__main__':
print "total points", total_points
d = {True: 0, False: 0}
good = []
bad = []
for cur_try in xrange(total_tries):
g = random_grid(total_points)
for cur_try in xrange(1,total_tries + 1):
d = {True: 0, False: 0}
g = random_grid(total_points * cur_try)
open('%s%0.3d.txt' % (FILE_PREFIX, cur_try), 'w').write(g.for_qhull())
for i in xrange(random_points):
@ -52,10 +55,10 @@ if __name__ == '__main__':
try:
try:
answer = g.run_baker(X)
answer = g.run_baker(X, order=2, extra_points=10)
d[improved_answer(answer, exact)] += 1
except ValueError as e:
log.error(e)
print e
except Exception as e:
print e
print d

View File

@ -1,5 +1,5 @@
from interp.grid.delaunay import dgrid as basegrid
from interp.tools import exact_func, log
from interp.tools import friendly_exact_2D as exact_func
import numpy as np
@ -29,13 +29,11 @@ class rect_grid(basegrid):
class random_grid(rect_grid):
def __init__(self, num_verts = 10):
log.debug("number of verts: %d" % num_verts)
verts = []
q = []
r = np.random
appx_side_res = int(np.sqrt(num_verts))
log.debug("appx_side_res: %d" % appx_side_res)
delta = 1.0 / float(appx_side_res)
for x in xrange(appx_side_res + 1):

View File

@ -1,5 +1,5 @@
from interp.grid.delaunay import dgrid as basegrid
from interp.tools import exact_func_3D, log
from interp.tools import baker_exact_3D, log
import numpy as np
@ -30,7 +30,7 @@ class rect_grid(basegrid):
for z in xrange(zres):
cur_z = zmin + (z * zdel)
verts.append([cur_x, cur_y, cur_z])
q.append(exact_func_3D((cur_x, cur_y, cur_z)))
q.append(baker_exact_3D((cur_x, cur_y, cur_z)))
basegrid.__init__(self, verts, q)
@ -55,8 +55,8 @@ class random_grid(rect_grid):
cur_z = r.rand()
verts.append([cur_x, cur_y, cur_z])
q.append(exact_func_3D((cur_x, cur_y, cur_z)))
rect_grid.__init__(self, verts, q)
q.append(baker_exact_3D((cur_x, cur_y, cur_z)))
basegrid.__init__(self, verts, q)
self.verts = np.array(self.verts)
self.q = np.array(self.q)