updated some imports

This commit is contained in:
Stephen Mardson McQuay 2010-11-08 16:25:09 -07:00
parent 93fec67cc7
commit 2471f650bc
5 changed files with 42 additions and 46 deletions

View File

@ -1,12 +1,9 @@
#!/usr/bin/env python
from baker import pattern
from baker.tools import smblog
from interp.baker import pattern
from interp.tools import log
smblog.info(pattern(power = 2, phicount = 3, offset = -1))
smblog.info()
smblog.info(pattern(power = 2, phicount = 4, offset = -1))
smblog.info()
smblog.info(pattern(power = 3, phicount = 3, offset = -1))
smblog.info()
smblog.info(pattern(power = 3, phicount = 4, offset = -1))
log.info(pattern(power = 2, phicount = 3, offset = -1))
log.info(pattern(power = 2, phicount = 4, offset = -1))
log.info(pattern(power = 3, phicount = 3, offset = -1))
log.info(pattern(power = 3, phicount = 4, offset = -1))

View File

@ -1,9 +1,9 @@
#!/usr/bin/env python
import sys
from grid.DDD import random_grid
from baker import get_phis, run_baker
from baker.tools import exact_func, smberror, improved_answer, smblog
from interp.grid.DDD import random_grid
from interp.baker import get_phis, run_baker
from interp.tools import exact_func, improved_answer, log
from glob import glob
from os import remove
@ -57,8 +57,8 @@ if __name__ == '__main__':
answer = g.run_baker(X)
d[improved_answer(answer, exact)] += 1
except ValueError as e:
smblog.error(e)
except smberror as e:
log.error(e)
except Exception as e:
print e
print d

View File

@ -1,12 +1,12 @@
#!/usr/bin/env python
from baker import run_baker
from baker.tools import improved_answer
from interp.baker import run_baker
from interp.tools import improved_answer
from baker.tools import smblog
from interp.tools import log
from grid.DD import grid
from grid.simplex import contains
from interp.grid.DD import grid
from interp.grid.simplex import contains
import numpy as np
@ -31,7 +31,6 @@ if __name__ == '__main__':
X = [0.55, 0.45]
g = grid(points, q)
g.construct_connectivity()
R = g.create_mesh(range(3))
try:
@ -44,6 +43,6 @@ if __name__ == '__main__':
for i in xrange(1,4):
answer = run_baker(X, R, S, i)
exact = exact_func(X)
smblog.debug(improved_answer(answer, exact))
log.debug(improved_answer(answer, exact))
smblog.debug(improved_answer(g.run_baker(X), exact))
log.debug(improved_answer(g.run_baker(X), exact))

View File

@ -1,4 +1,4 @@
from interp.grid import grid as basegrid
from interp.grid import delaunay_grid as basegrid
from interp.tools import exact_func, log

View File

@ -1,12 +1,12 @@
from grid import grid as basegrid
from baker.tools import exact_func_3D, smblog
from interp.grid import delaunay_grid as basegrid
from interp.tools import exact_func_3D, log
import numpy as np
class grid(basegrid):
def __init__(self, points, q):
basegrid.__init__(self, points, q)
def __init__(self, verts, q):
basegrid.__init__(self, verts, q)
def for_qhull_generator(self):
"""
@ -14,9 +14,9 @@ class grid(basegrid):
"""
yield '3';
yield '%d' % len(self.points)
yield '%d' % len(self.verts)
for p in self.points:
for p in self.verts:
yield "%f %f %f" % tuple(p)
def for_qhull(self):
@ -24,8 +24,8 @@ class grid(basegrid):
this returns a single string that should be fed into qdelaunay
"""
r = '3\n'
r += '%d\n' % len(self.points)
for p in self.points:
r += '%d\n' % len(self.verts)
for p in self.verts:
r += "%f %f %f\n" % tuple(p)
return r
@ -47,7 +47,7 @@ class rect_grid(grid):
zdel = zspan / float(zres - 1)
points = []
verts = []
q = []
for x in xrange(xres):
cur_x = xmin + (x * xdel)
@ -55,9 +55,9 @@ class rect_grid(grid):
cur_y = ymin + (y * ydel)
for z in xrange(zres):
cur_z = zmin + (z * zdel)
points.append([cur_x, cur_y, cur_z])
verts.append([cur_x, cur_y, cur_z])
q.append(exact_func_3D((cur_x, cur_y, cur_z)))
grid.__init__(self, points, q)
grid.__init__(self, verts, q)
# self.construct_connectivity()
def for_qhull_generator(self):
@ -66,9 +66,9 @@ class rect_grid(grid):
"""
yield '3';
yield '%d' % len(self.points)
yield '%d' % len(self.verts)
for p in self.points:
for p in self.verts:
yield "%f %f %f" % tuple(p)
def for_qhull(self):
@ -76,33 +76,33 @@ class rect_grid(grid):
this returns a single string that should be fed into qdelaunay
"""
r = '3\n'
r += '%d\n' % len(self.points)
for p in self.points:
r += '%d\n' % len(self.verts)
for p in self.verts:
r += "%f %f %f\n" % tuple(p)
return r
class random_grid(rect_grid):
def __init__(self, num_points = 10):
points = []
def __init__(self, num_verts = 10):
verts = []
q = []
r = np.random
appx_side_res = int(np.power(num_points, 1/3.0))
smblog.debug("appx_side_res: %d" % appx_side_res)
appx_side_res = int(np.power(num_verts, 1/3.0))
log.debug("appx_side_res: %d" % appx_side_res)
delta = 1.0 / float(appx_side_res)
for x in xrange(appx_side_res + 1):
pass
for i in xrange(num_points):
for i in xrange(num_verts):
cur_x = r.rand()
cur_y = r.rand()
cur_z = r.rand()
points.append([cur_x, cur_y, cur_z])
verts.append([cur_x, cur_y, cur_z])
q.append(exact_func_3D((cur_x, cur_y, cur_z)))
grid.__init__(self, points, q)
grid.__init__(self, verts, q)
self.points = np.array(self.points)
self.verts = np.array(self.verts)
self.q = np.array(self.q)