From 4b113b8eb25f6db70c4dea4dfd8b03946f4ca816 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Wed, 26 Feb 2020 12:32:44 -0600 Subject: [PATCH 1/2] Rotation matrix builder: don't build matrices for zero-length arrays See pytential#141 --- boxtree/pyfmmlib_integration.py | 5 +++++ test/test_fmm.py | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/boxtree/pyfmmlib_integration.py b/boxtree/pyfmmlib_integration.py index da56c1e..2b731f0 100644 --- a/boxtree/pyfmmlib_integration.py +++ b/boxtree/pyfmmlib_integration.py @@ -682,6 +682,11 @@ class FMMLibExpansionWrangler(object): m2l_rotation_angles = self.rotation_data.m2l_rotation_angles() + if not m2l_rotation_angles: + # The pyfmmlib wrapper may or may not complain if you give it a + # zero-length array. + return (rotmatf, rotmatb, rotmat_order) + def mem_estimate(order): # Rotation matrix memory cost estimate. return (8 diff --git a/test/test_fmm.py b/test/test_fmm.py index 2bd3f21..b5d2e1a 100644 --- a/test/test_fmm.py +++ b/test/test_fmm.py @@ -725,7 +725,9 @@ def test_fmm_float32(ctx_factory, enable_extents): @pytest.mark.parametrize("well_sep_is_n_away", (1, 2)) @pytest.mark.parametrize("helmholtz_k", (0, 2)) -def test_fmm_with_optimized_3d_m2l(ctx_factory, helmholtz_k, well_sep_is_n_away): +@pytest.mark.parametrize("nsrcntgts", (20, 10000)) +def test_fmm_with_optimized_3d_m2l(ctx_factory, nsrcntgts, helmholtz_k, + well_sep_is_n_away): logging.basicConfig(level=logging.INFO) from pytest import importorskip @@ -736,8 +738,7 @@ def test_fmm_with_optimized_3d_m2l(ctx_factory, helmholtz_k, well_sep_is_n_away) ctx = ctx_factory() queue = cl.CommandQueue(ctx) - nsources = 5000 - ntargets = 5000 + nsources = ntargets = nsrcntgts // 2 dtype = np.float64 sources = p_normal(queue, nsources, dims, dtype, seed=15) -- GitLab From de415ab6af851180a836d0be06ec0040d5b1bce7 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Wed, 26 Feb 2020 12:38:26 -0600 Subject: [PATCH 2/2] Don't use a deprecated numpy feature --- boxtree/pyfmmlib_integration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boxtree/pyfmmlib_integration.py b/boxtree/pyfmmlib_integration.py index 2b731f0..47c617d 100644 --- a/boxtree/pyfmmlib_integration.py +++ b/boxtree/pyfmmlib_integration.py @@ -682,7 +682,7 @@ class FMMLibExpansionWrangler(object): m2l_rotation_angles = self.rotation_data.m2l_rotation_angles() - if not m2l_rotation_angles: + if len(m2l_rotation_angles) == 0: # The pyfmmlib wrapper may or may not complain if you give it a # zero-length array. return (rotmatf, rotmatb, rotmat_order) -- GitLab