diff --git a/bin/test.py b/bin/test.py index 4a73b28..11786d0 100755 --- a/bin/test.py +++ b/bin/test.py @@ -30,7 +30,6 @@ phis = get_phis_3D(X, R.points) print "phi values (should all be positive): ", phis, sum(phis) if [i for i in phis if i < 0.0]: print "problems" - sys.exit(1) r = run_baker_3D(X, R, S) @@ -40,7 +39,5 @@ print 'final', r['final'] if abs(r['final'] - exact) <= abs(r['qlin'] - exact): print "win" - sys.exit(0) else: print "failure" - sys.exit(2) diff --git a/lib/baker/baker.py b/lib/baker/baker.py index 84fe422..6f4c4cc 100644 --- a/lib/baker/baker.py +++ b/lib/baker/baker.py @@ -27,7 +27,7 @@ def get_phis(X, R): ]) try: phi = np.linalg.solve(A,b) - except LinAlgError as e: + except np.linalg.LinAlgError as e: print >> sys.stderr, "warning: get_phis: calculation of phis yielded a linearly dependant system", e raise smberror('get_phis') phi = np.dot(np.linalg.pinv(A), b) @@ -65,7 +65,7 @@ def get_phis_3D(X, r): ]) try: phi = np.linalg.solve(A,b) - except LinAlgError as e: + except np.linalg.LinAlgError as e: print >> sys.stderr, "warning: get_phis_3D: calculation of phis yielded a linearly dependant system", e phi = np.dot(np.linalg.pinv(A), b) @@ -113,8 +113,14 @@ def run_baker(X, R, S): # calculate values only for the simplex triangle phi, qlin = qlinear(X, R) + if [i for i in phi if i <= 0.0]: - print "failure" + s = "this is not a containing simplex:\n" + s += " X: %s\n" % X + s += " R: %s\n" % R + s += " phi: %s, sum(%0.4e)\n" % (phi, sum(phi)) + print >> sys.stderr, s + raise smberror("not containing simplex") if len(S.points) == 0: answer = { @@ -152,7 +158,7 @@ def run_baker(X, R, S): # baker solve eq 10 try: (a, b, c) = np.linalg.solve(A,b) - except LinAlgError as e: + except np.linalg.LinAlgError as e: print >> sys.stderr, "warning: run_baker: linear calculation went bad, resorting to np.linalg.pinv", e (a, b, c) = np.dot(np.linalg.pinv(A), b) @@ -187,6 +193,14 @@ def run_baker_3D(X, R, S): # calculate values only for the triangle phi, qlin = qlinear_3D(X, R) + if [i for i in phi if i <= 0.0]: + s = "this is not a containing simplex:\n" + s += " X: %s\n" % X + s += " R: %s\n" % R + s += " phi: %s, sum(%0.4e)\n" % (phi, sum(phi)) + print >> sys.stderr, s + raise smberror("not containing simplex") + if len(S.points) == 0: answer = { 'a': None, diff --git a/test/baker.test.py b/test/baker.test.py index be0c934..7808f4d 100755 --- a/test/baker.test.py +++ b/test/baker.test.py @@ -22,7 +22,7 @@ class TestSequenceFunctions(unittest.TestCase): [-1,-1], # 8 ] self.q = [1, 0, 0, 0, 0, 0, 0, 0, 0] - self.X = [1.5, 10.25] + self.X = [0.5, 0.25] self.accuracy = 8 def testImports(self):