From aadb66dad6b30074c9611f58e7a202594c75ee20 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Fri, 1 Jun 2018 22:11:21 -0500 Subject: [PATCH 1/3] Fix TODO relating to strictness of target association test. --- test/test_global_qbx.py | 49 ++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/test/test_global_qbx.py b/test/test_global_qbx.py index e7a4eaa6..d0128819 100644 --- a/test/test_global_qbx.py +++ b/test/test_global_qbx.py @@ -217,13 +217,7 @@ def test_source_refinement_3d(ctx_getter, surface_name, surface_f, order): @pytest.mark.parametrize(("curve_name", "curve_f", "nelements"), [ - # TODO: This used to pass for a 20-to-1 ellipse (with different center - # placement). It still produces valid output right now, but the current - # test is not smart enough to recognize it. It might be useful to fix that. - # - # See discussion at - # https://gitlab.tiker.net/inducer/pytential/merge_requests/95#note_24003 - ("18-to-1 ellipse", partial(ellipse, 18), 100), + ("20-to-1 ellipse", partial(ellipse, 20), 100), ("horseshoe", horseshoe, 64), ]) def test_target_association(ctx_getter, curve_name, curve_f, nelements, @@ -320,6 +314,8 @@ def test_target_association(ctx_getter, curve_name, curve_f, nelements, expansion_radii = lpot_source._expansion_radii("ncenters").get(queue) + surf_targets = np.array( + [axis.get(queue) for axis in lpot_source.density_discr.nodes()]) int_targets = np.array([axis.get(queue) for axis in int_targets.nodes()]) ext_targets = np.array([axis.get(queue) for axis in ext_targets.nodes()]) @@ -352,48 +348,45 @@ def test_target_association(ctx_getter, curve_name, curve_f, nelements, if visualize: visualize_curve_and_assoc() - # Checks that the sources match with their own centers. - def check_on_surface_targets(nsources, true_side, target_to_center, - target_to_side_result): - assert (target_to_center >= 0).all() - - sources = np.arange(0, nsources) - - # Centers are on alternating sides of the geometry. Dividing by - # two yields the number of the source that spawned the center. - assert (target_to_center//2 == sources).all() - - assert (target_to_side_result == true_side).all() - # Checks that the targets match with centers on the appropriate side and # within the allowable distance. def check_close_targets(centers, targets, true_side, target_to_center, target_to_side_result, tgt_slice): - assert (target_to_center >= 0).all() + targets_have_centers = (target_to_center >= 0).all() + assert targets_have_centers + assert (target_to_side_result == true_side).all() + + TOL = 1e-3 dists = la.norm((targets.T - centers.T[target_to_center]), axis=1) - assert (dists <= expansion_radii[target_to_center]).all() + assert (dists <= (1 + TOL) * expansion_radii[target_to_center]).all() # Center side order = -1, 1, -1, 1, ... target_to_center_side = 2 * (target_assoc.target_to_center % 2) - 1 - check_on_surface_targets( - nsources, -1, + # interior surface + check_close_targets( + centers, surf_targets, -1, target_assoc.target_to_center[surf_int_slice], - target_to_center_side[surf_int_slice]) + target_to_center_side[surf_int_slice], + surf_int_slice) - check_on_surface_targets( - nsources, +1, + # exterior surface + check_close_targets( + centers, surf_targets, +1, target_assoc.target_to_center[surf_ext_slice], - target_to_center_side[surf_ext_slice]) + target_to_center_side[surf_ext_slice], + surf_ext_slice) + # interior volume check_close_targets( centers, int_targets, -1, target_assoc.target_to_center[vol_int_slice], target_to_center_side[vol_int_slice], vol_int_slice) + # exterior volume check_close_targets( centers, ext_targets, +1, target_assoc.target_to_center[vol_ext_slice], -- GitLab From 0328f366ffd462e7c3d131c2a64c0e8cec1eced6 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Fri, 1 Jun 2018 22:12:21 -0500 Subject: [PATCH 2/3] Address a FIXME regarding a sloppy tolerance - the new version of the algorithm meets a strict tolerance. --- test/test_layer_pot.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test_layer_pot.py b/test/test_layer_pot.py index 3e50aa94..b59af654 100644 --- a/test/test_layer_pot.py +++ b/test/test_layer_pot.py @@ -139,8 +139,7 @@ def test_off_surface_eval(ctx_getter, use_fmm, do_plot=False): pt.colorbar() pt.show() - # FIXME: Why does the FMM only meet this sloppy tolerance? - assert linf_err < 1e-2 + assert linf_err < 1e-14 # }}} -- GitLab From 465b322b593d2b1af3abb8df816e4c28ea3b6190 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Sun, 3 Jun 2018 18:39:01 -0500 Subject: [PATCH 3/3] Loosen tolerance, and don't use "is True" for truth testing. --- test/test_layer_pot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_layer_pot.py b/test/test_layer_pot.py index b59af654..66445fee 100644 --- a/test/test_layer_pot.py +++ b/test/test_layer_pot.py @@ -92,7 +92,7 @@ def test_off_surface_eval(ctx_getter, use_fmm, do_plot=False): nelements = 30 target_order = 8 qbx_order = 3 - if use_fmm is True: + if use_fmm: fmm_order = qbx_order else: fmm_order = False @@ -139,7 +139,7 @@ def test_off_surface_eval(ctx_getter, use_fmm, do_plot=False): pt.colorbar() pt.show() - assert linf_err < 1e-14 + assert linf_err < 1e-3 # }}} -- GitLab