simplified a module, and adjusted tests for imports
This commit is contained in:
parent
0eb9c4102d
commit
b54272bb85
@ -1,4 +1,4 @@
|
|||||||
a = 0.0885;
|
a = 0.885;
|
||||||
Point(0) = {0, 0, 0, a};
|
Point(0) = {0, 0, 0, a};
|
||||||
Point(1) = {1, 0, 0, a};
|
Point(1) = {1, 0, 0, a};
|
||||||
Point(2) = {1, 1, 0, a};
|
Point(2) = {1, 1, 0, a};
|
||||||
|
@ -8,7 +8,7 @@ import numpy as np
|
|||||||
from scipy.spatial import KDTree
|
from scipy.spatial import KDTree
|
||||||
|
|
||||||
from interp.baker import run_baker
|
from interp.baker import run_baker
|
||||||
import interp.grid.simplex
|
from interp.baker import get_phis
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger("interp")
|
log = logging.getLogger("interp")
|
||||||
@ -233,7 +233,7 @@ class cell(object):
|
|||||||
|
|
||||||
this simply calls grid.simplex.contains
|
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):
|
def __str__(self):
|
||||||
# neighbors = [str(i.name) for i in self.neighbors]
|
# neighbors = [str(i.name) for i in self.neighbors]
|
||||||
@ -246,3 +246,23 @@ class cell(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
__repr__ = __str__
|
__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
|
||||||
|
@ -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
|
|
@ -6,7 +6,7 @@ from interp import baker
|
|||||||
from interp.grid import grid
|
from interp.grid import grid
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from interp.grid.simplex import contains
|
from interp.grid import contains
|
||||||
|
|
||||||
def exact_func(point):
|
def exact_func(point):
|
||||||
x = point[0]
|
x = point[0]
|
||||||
@ -78,8 +78,8 @@ class Test(unittest.TestCase):
|
|||||||
self.answer = baker.run_baker(self.X,self.R,self.S)
|
self.answer = baker.run_baker(self.X,self.R,self.S)
|
||||||
|
|
||||||
|
|
||||||
# def test_R_contains_X(self):
|
def test_R_contains_X(self):
|
||||||
# self.assertTrue(contains(self.X, self.R.verts))
|
self.assertTrue(contains(self.X, self.R.verts))
|
||||||
|
|
||||||
def test_1(self):
|
def test_1(self):
|
||||||
a,b,c,d,e,f = (0,1, 1,2, 2,0)
|
a,b,c,d,e,f = (0,1, 1,2, 2,0)
|
||||||
|
@ -5,7 +5,7 @@ import unittest
|
|||||||
from interp.baker import run_baker
|
from interp.baker import run_baker
|
||||||
|
|
||||||
from interp.grid import grid
|
from interp.grid import grid
|
||||||
from interp.grid.simplex import contains
|
from interp.grid import contains
|
||||||
|
|
||||||
def exact_func(X):
|
def exact_func(X):
|
||||||
x = X[0]
|
x = X[0]
|
||||||
|
@ -5,7 +5,7 @@ import unittest
|
|||||||
from interp.baker import run_baker
|
from interp.baker import run_baker
|
||||||
|
|
||||||
from interp.grid import grid
|
from interp.grid import grid
|
||||||
from interp.grid.simplex import contains
|
from interp.grid import contains
|
||||||
|
|
||||||
def exact_func(X):
|
def exact_func(X):
|
||||||
x = X[0]
|
x = X[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user