meshpro / dmsh

:spider_web: Simple mesh generator inspired by distmesh.
GNU General Public License v3.0
210 stars 26 forks source link

tests failing norm_equality assertions #10

Closed drew-parsons closed 4 years ago

drew-parsons commented 4 years ago

Debian CI tests for dmsh are failing norm_equality assertions, see https://ci.debian.net/packages/p/python-dmsh/unstable/amd64/

e.g.

running test_ellipse.py
Traceback (most recent call last):
  File "test_ellipse.py", line 17, in <module>
    X, cells = test_ellipse(show=False)
  File "test_ellipse.py", line 12, in test_ellipse
    assert_norm_equality(X.flatten(), ref_norms, 1.0e-12)
  File "/tmp/autopkgtest-lxc.gfrwhpig/downtmp/build.UWT/src/test/helpers.py", line 16, in assert_norm_equality
    *ref_norm, *vals
AssertionError: Expected: [2.5108886251367960e+02, 1.5652935519539316e+01, 1.9890059982474428e+00]
Computed: [2.5384746773734730e+02, 1.5749252942957204e+01, 1.9968359662268518e+00]

It looks like it's not as simple as just relaxing the tolerance from 1e-12. The amount of deviation is larger than 1%, too large to be just an issue of machine precision.

Unfortunately I can't reproduce the error on my own computer, where the tests pass fine, so difficult to debug.

nschloe commented 4 years ago

Phew, that's a tough one. I just tried it on two different machines and couldn't reproduce the failure either. I'd suggest relaxing the test tolerance to 1.0e-1 (or whatever is needed) until we found the issue.

nschloe commented 4 years ago

I was able to reproduce this on my own machine now; probably some update caused this. I've now relaxed the test tolerances quite a bit, hopefully that'll also satisfy the debian builds.

drew-parsons commented 4 years ago

Finally I've had to use these tolerances

--- a/test/test_translation.py
+++ b/test/test_translation.py
@@ -7,7 +7,7 @@
     X, cells = dmsh.generate(geo, 0.1, show=show)

     ref_norms = [1.7525e03, 5.5677441324948013e01, 3.0]
-    assert_norm_equality(X.flatten(), ref_norms, 1.0e-10)
+    assert_norm_equality(X.flatten(), ref_norms, 1.0e-5)

 if __name__ == "__main__":
--- a/test/test_halfspace.py
+++ b/test/test_halfspace.py
@@ -14,7 +14,7 @@
     X, cells = dmsh.generate(geo, 0.1, show=show)

     ref_norms = [1.6445971629723411e02, 1.0032823867864321e01, 9.9962000746451751e-01]
-    assert_norm_equality(X.flatten(), ref_norms, 1.0e-10)
+    assert_norm_equality(X.flatten(), ref_norms, 1.0e-7)
     return X, cells

--- a/test/test_refinement_point_line.py
+++ b/test/test_refinement_point_line.py
@@ -14,7 +14,7 @@
     X, cells = dmsh.generate(geo, edge_size, show=show, tol=1.0e-10)

     ref_norms = [3.8844963377954718e02, 1.5689926870601147e01, 1.0000000000000000e00]
-    assert_norm_equality(X.flatten(), ref_norms, 1.0e-3)
+    assert_norm_equality(X.flatten(), ref_norms, 2.0e-3)
     return X, cells

--- a/test/test_square_hole_refined.py
+++ b/test/test_square_hole_refined.py
@@ -14,7 +14,7 @@
     )

     ref_norms = [2.48e02, 1.200e01, 1.0]
-    assert_norm_equality(X.flatten(), ref_norms, 1.0e-3)
+    assert_norm_equality(X.flatten(), ref_norms, 4.0e-3)
     return X, cells

test_refinement_point_line.py and test_square_hole_refined.py needed to be relaxed for arm64, ppc64el, but the other 2 affected amd64.

nschloe commented 4 years ago

Feel free to PR those, I'll merge it if it makes things easier for you.

griff10000 commented 4 years ago

Not sure if this is the same problem, but creating an ellipse generates spurious points on the periphery. Windows 10, python 3.8.3, Anaconda.

import dmsh
geo = dmsh.Ellipse([0.0, 0.0], 2.0, 1.0)

edge_size=0.2

X, cells = dmsh.generate(geo, edge_size, tol=1.0e-10) # does not help

dmsh.helpers.show(X, cells, geo)

ellipse

nschloe commented 4 years ago

@griff10000 It's not the same issue.