Skip to content

Commit d1ff1c6

Browse files
authored
Merge pull request #162 from nschloe/abstol
tests: absolute tolerance
2 parents de90660 + 3ac4898 commit d1ff1c6

8 files changed

Lines changed: 49 additions & 24 deletions

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Run pre-commit
2020
uses: pre-commit/action@v2.0.3
2121

22-
build:
22+
linux:
2323
runs-on: ubuntu-20.04
2424
steps:
2525
- uses: actions/setup-python@v2
@@ -43,3 +43,20 @@ jobs:
4343
pip install tox
4444
CC="clang" tox -- --cov pygalmesh --cov-report xml --cov-report term
4545
- uses: codecov/codecov-action@v1
46+
47+
macos:
48+
runs-on: macos-latest
49+
steps:
50+
- uses: actions/setup-python@v2
51+
with:
52+
python-version: "3.x"
53+
- uses: actions/checkout@v2
54+
with:
55+
lfs: true
56+
- name: Install system dependencies
57+
run: |
58+
brew install cgal eigen
59+
- name: Test with tox
60+
run: |
61+
pip install tox
62+
CC="clang" tox -- --cov pygalmesh --cov-report xml --cov-report term

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = pygalmesh
3-
version = 0.10.3
3+
version = 0.10.4
44
author = Nico Schlömer
55
author_email = nico.schloemer@gmail.com
66
description = Python frontend to CGAL's mesh generation capabilities

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
"src/pybind11.cpp",
2222
]
2323
),
24-
include_dirs=[os.environ.get("EIGEN_INCLUDE_DIR", "/usr/include/eigen3/")],
24+
include_dirs=[
25+
os.environ.get("EIGEN_INCLUDE_DIR", "/usr/include/eigen3/"),
26+
# macos/brew:
27+
"/usr/local/include/eigen3",
28+
],
2529
# no CGAL libraries necessary from CGAL 5.0 onwards
2630
libraries=["gmp", "mpfr"],
2731
)

tests/test_from_array.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ def test_from_array():
2424

2525
tol = min(h)
2626
ref = [1.0, 0.0, 1.0, 0.0, 1.0, 0.0]
27-
assert abs(max(mesh.points[:, 0]) - ref[0]) < tol
28-
assert abs(min(mesh.points[:, 0]) - ref[1]) < tol
29-
assert abs(max(mesh.points[:, 1]) - ref[2]) < tol
30-
assert abs(min(mesh.points[:, 1]) - ref[3]) < tol
31-
assert abs(max(mesh.points[:, 2]) - ref[4]) < tol
32-
assert abs(min(mesh.points[:, 2]) - ref[5]) < tol
27+
assert abs(max(mesh.points[:, 0]) - ref[0]) < (1.0 + ref[0]) * tol
28+
assert abs(min(mesh.points[:, 0]) - ref[1]) < (1.0 + ref[1]) * tol
29+
assert abs(max(mesh.points[:, 1]) - ref[2]) < (1.0 + ref[2]) * tol
30+
assert abs(min(mesh.points[:, 1]) - ref[3]) < (1.0 + ref[3]) * tol
31+
assert abs(max(mesh.points[:, 2]) - ref[4]) < (1.0 + ref[4]) * tol
32+
assert abs(min(mesh.points[:, 2]) - ref[5]) < (1.0 + ref[5]) * tol
3333

3434
vol = sum(helpers.compute_volumes(mesh.points, mesh.get_cells_type("tetra")))
3535
ref = 1.0 / 6.0 * np.pi

tests/test_inr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_inr():
3535
(min(mesh.points[:, 2]), -3.98639357e-03),
3636
]
3737
for val, ref in vals_refs:
38-
assert abs(val - ref) < 6.0e-2 * abs(ref), f"{val:.8e} != {ref:.8e}"
38+
assert abs(val - ref) < 1.0e-3 * (1.0 + abs(ref)), f"{val:.8e} != {ref:.8e}"
3939

4040
vol = sum(helpers.compute_volumes(mesh.points, mesh.get_cells_type("tetra")))
4141
ref = 6.95558790e02

tests/test_remesh_surface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_remesh_surface():
4646
(min(mesh.points[:, 2]), -3.01316000e-01),
4747
]
4848
for val, ref in vals_refs:
49-
assert abs(val - ref) < 1.0e-3 * abs(ref), f"{val:.8e} != {ref:.8e}"
49+
assert abs(val - ref) < 1.0e-3 * (1.0 + abs(ref)), f"{val:.8e} != {ref:.8e}"
5050

5151
triangle_areas = helpers.compute_triangle_areas(
5252
mesh.points, mesh.get_cells_type("triangle")

tests/test_surface_mesh.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ def test_sphere():
1616
)
1717

1818
tol = 1.0e-2
19-
assert abs(max(mesh.points[:, 0]) - radius) < tol
20-
assert abs(min(mesh.points[:, 0]) + radius) < tol
21-
assert abs(max(mesh.points[:, 1]) - radius) < tol
22-
assert abs(min(mesh.points[:, 1]) + radius) < tol
23-
assert abs(max(mesh.points[:, 2]) - radius) < tol
24-
assert abs(min(mesh.points[:, 2]) + radius) < tol
19+
assert abs(max(mesh.points[:, 0]) - radius) < (1.0 + radius) * tol
20+
assert abs(min(mesh.points[:, 0]) + radius) < (1.0 + radius) * tol
21+
assert abs(max(mesh.points[:, 1]) - radius) < (1.0 + radius) * tol
22+
assert abs(min(mesh.points[:, 1]) + radius) < (1.0 + radius) * tol
23+
assert abs(max(mesh.points[:, 2]) - radius) < (1.0 + radius) * tol
24+
assert abs(min(mesh.points[:, 2]) + radius) < (1.0 + radius) * tol
2525

2626
areas = helpers.compute_triangle_areas(mesh.points, mesh.get_cells_type("triangle"))
2727
surface_area = sum(areas)

tests/test_volume_from_surface.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ def test_volume_from_surface():
3838
mesh = meshio.read(out_filename)
3939

4040
tol = 2.0e-2
41-
assert abs(max(mesh.points[:, 0]) - 0.357612477657) < tol
42-
assert abs(min(mesh.points[:, 0]) + 0.358747130015) < tol
43-
assert abs(max(mesh.points[:, 1]) - 0.496137874959) < tol
44-
assert abs(min(mesh.points[:, 1]) + 0.495301051456) < tol
45-
assert abs(max(mesh.points[:, 2]) - 0.298780230629) < tol
46-
assert abs(min(mesh.points[:, 2]) + 0.300472866512) < tol
41+
vals_refs = [
42+
(max(mesh.points[:, 0]), +0.357612477657),
43+
(min(mesh.points[:, 0]), -0.358747130015),
44+
(max(mesh.points[:, 1]), +0.496137874959),
45+
(min(mesh.points[:, 1]), -0.495301051456),
46+
(max(mesh.points[:, 2]), +0.298780230629),
47+
(min(mesh.points[:, 2]), -0.300472866512),
48+
]
49+
for val, ref in vals_refs:
50+
assert abs(val - ref) < (1.0 + ref) * tol, f"{val:.15e} != {ref:.15e}"
4751

4852
vol = sum(helpers.compute_volumes(mesh.points, mesh.get_cells_type("tetra")))
49-
assert abs(vol - 0.044164693065) < tol
53+
assert abs(vol - 0.044164693065) < (1.0 + vol) * tol

0 commit comments

Comments
 (0)