Skip to content

Commit

Permalink
Fix some flakey tests in test_triangle.py
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-vv committed Nov 10, 2024
1 parent 1087ec9 commit ed33835
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/test_triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def potential_exact_integrated(v0, v1, v2, target):
area = np.linalg.norm(np.cross(v1-v0, v2-v0))/2
return dblquad(potential_exact, 0, 1, 0, lambda x: 1-x, epsabs=1e-10, epsrel=1e-10, args=(target, (v0, v1, v2)))[0] * (2*area)

def flux_exact_integrated(v0, v1, v2, target, normal):
def flux_exact_integrated(v0, v1, v2, target, normal, epsabs=1e-10, epsrel=1e-10):
area = np.linalg.norm(np.cross(v1-v0, v2-v0))/2
return dblquad(flux_exact, 0, 1, 0, lambda x: 1-x, epsabs=1e-10, epsrel=1e-10, args=(target, (v0, v1, v2), normal))[0] * (2*area)
return dblquad(flux_exact, 0, 1, 0, lambda x: 1-x, epsabs=epsabs, epsrel=epsrel, args=(target, (v0, v1, v2), normal))[0] * (2*area)


class TestTriangle(unittest.TestCase):
Expand Down Expand Up @@ -67,7 +67,7 @@ def test(a, b, c):

correct = potential_exact_integrated(v0, v1, v2, target)
approx = B.self_potential_triangle(v0, v1, v2, target)
assert np.isclose(approx, correct, atol=0., rtol=1e-12), (a,b,c)
assert np.isclose(approx, correct, atol=0., rtol=5e-10), (a,b,c)

for (a,b,c) in rand(3, 3):
test(a,b,c)
Expand Down Expand Up @@ -145,7 +145,7 @@ def test(x0, a, b, c, z0):
target = np.array([0., 0., z0])
normal = np.array([1., 0., 0.])

correct = flux_exact_integrated(v0, v1, v2, target, [1., 0, 0])
correct = flux_exact_integrated(v0, v1, v2, target, [1., 0, 0], epsabs=1e-11, epsrel=1e-11)
approx = B.flux_triangle(v0, v1, v2, target, normal)
assert np.isclose(correct, approx, atol=0., rtol=1e-9), (x0, a,b,c, z0)

Expand Down

0 comments on commit ed33835

Please sign in to comment.