From 0a388ff1b55c2de8803aabe239b1e2729fd84cb4 Mon Sep 17 00:00:00 2001 From: Stephen Mardson McQuay Date: Fri, 23 Apr 2010 09:58:30 -0600 Subject: [PATCH] trying to guarantee a containing simplex --- bin/test.py | 20 +++++++++----------- lib/baker/tools.py | 10 ++++++++++ lib/grid/__init__.py | 6 +++++- test/cubic.test.py | 1 - 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/bin/test.py b/bin/test.py index 0ff5e48..34a462d 100755 --- a/bin/test.py +++ b/bin/test.py @@ -3,8 +3,7 @@ import sys from grid.DDD import random_grid from baker import get_phis_3D, run_baker_3D -from baker.tools import exact_func_3D, smberror - +from baker.tools import exact_func_3D, smberror, evaluate_answer try: total_points = int(sys.argv[1]) except: @@ -33,14 +32,13 @@ if [i for i in phis if i < 0.0]: try: r = run_baker_3D(X, R, S) - print 'qlin' , r['qlin'] - print 'error', r['error'] - print 'final', r['final'] - - if abs(r['final'] - exact) <= abs(r['qlin'] - exact): - print "win" - else: - print "failure" + evaluate_answer(r, exact) +except smberror as e: + print e + + +try: + answer = g.run_baker(X) + evaluate_answer(answer, exact) except smberror as e: print e - print 'TAINT' diff --git a/lib/baker/tools.py b/lib/baker/tools.py index de417fc..673360f 100644 --- a/lib/baker/tools.py +++ b/lib/baker/tools.py @@ -35,3 +35,13 @@ def exact_func_3D(X): y = X[1] z = X[2] return np.power((np.sin(x * np.pi / 2.0) * np.sin(y * np.pi / 2.0) * np.sin(z * np.pi / 2.0)), 2) + +def evaluate_answer(answer, exact): + print 'qlin' , answer['qlin'] + print 'error', answer['error'] + print 'final', answer['final'] + + if abs(answer['final'] - exact) <= abs(answer['qlin'] - exact): + print ":) improved result" + else: + print ":( damaged result" diff --git a/lib/grid/__init__.py b/lib/grid/__init__.py index dd92f54..fc10e2a 100644 --- a/lib/grid/__init__.py +++ b/lib/grid/__init__.py @@ -54,7 +54,9 @@ class grid(object): """ this returns two grid objects: R and S. - R is a grid object that is the (a) containing simplex around point X + R is a grid object that is supposedly a containing simplex + around point X (it tends not to be) + S is S_j from baker's paper : some points from all point that are not the simplex """ (dist, indicies) = self.tree.query(X, simplex_size + extra_points) @@ -78,6 +80,8 @@ class grid(object): points near a short edge in a boundary layer cell where the nearest points would all be colinear + also, it guarantees that we find a containing simplex + R is a grid object that is the (a) containing simplex around point X S is a connectivity-based nearest-neighbor lookup, limited to 3 extra points """ diff --git a/test/cubic.test.py b/test/cubic.test.py index d6a128b..98568b2 100755 --- a/test/cubic.test.py +++ b/test/cubic.test.py @@ -28,7 +28,6 @@ class TestSequenceFunctions(unittest.TestCase): ] self.q = [exact_func(p) for p in self.points] - self.X = [0.25, 0.4001] self.X = [0.55, 0.45] self.g = grid(self.points, self.q)