simplified a module, and adjusted tests for imports

This commit is contained in:
Stephen McQuay 2011-06-07 21:43:03 -06:00
parent 0eb9c4102d
commit b54272bb85
6 changed files with 32 additions and 32 deletions

View File

@ -1,4 +1,4 @@
a = 0.0885;
a = 0.885;
Point(0) = {0, 0, 0, a};
Point(1) = {1, 0, 0, a};
Point(2) = {1, 1, 0, a};

View File

@ -8,7 +8,7 @@ import numpy as np
from scipy.spatial import KDTree
from interp.baker import run_baker
import interp.grid.simplex
from interp.baker import get_phis
import logging
log = logging.getLogger("interp")
@ -233,7 +233,7 @@ class cell(object):
this simply calls grid.simplex.contains
"""
return interp.grid.simplex.contains(X, [G.verts[i] for i in self.verts])
return contains(X, [G.verts[i] for i in self.verts])
def __str__(self):
# neighbors = [str(i.name) for i in self.neighbors]
@ -246,3 +246,23 @@ class cell(object):
)
__repr__ = __str__
TOL = 1e-8
def contains(X, R):
"""
tests if X (point) is in R
R is a simplex, represented by a list of n-degree coordinates
it now correctly checks for 2/3-D verts
TODO: write unit test ...
"""
phis = get_phis(X, R)
r = True
if [i for i in phis if i < 0.0 - TOL]:
r = False
return r

View File

@ -1,20 +0,0 @@
from interp.baker import get_phis
TOL = 1e-8
def contains(X, R):
"""
tests if X (point) is in R
R is a simplex, represented by a list of n-degree coordinates
it now correctly checks for 2/3-D verts
TODO: write unit test ...
"""
phis = get_phis(X, R)
r = True
if [i for i in phis if i < 0.0 - TOL]:
r = False
return r

View File

@ -6,7 +6,7 @@ from interp import baker
from interp.grid import grid
import numpy as np
from interp.grid.simplex import contains
from interp.grid import contains
def exact_func(point):
x = point[0]
@ -78,8 +78,8 @@ class Test(unittest.TestCase):
self.answer = baker.run_baker(self.X,self.R,self.S)
# def test_R_contains_X(self):
# self.assertTrue(contains(self.X, self.R.verts))
def test_R_contains_X(self):
self.assertTrue(contains(self.X, self.R.verts))
def test_1(self):
a,b,c,d,e,f = (0,1, 1,2, 2,0)

View File

@ -2,10 +2,10 @@
import unittest
from interp.baker import run_baker
from interp.baker import run_baker
from interp.grid import grid
from interp.grid.simplex import contains
from interp.grid import grid
from interp.grid import contains
def exact_func(X):
x = X[0]

View File

@ -2,10 +2,10 @@
import unittest
from interp.baker import run_baker
from interp.baker import run_baker
from interp.grid import grid
from interp.grid.simplex import contains
from interp.grid import grid
from interp.grid import contains
def exact_func(X):
x = X[0]