From 66fb401da8a85cb33e538feccaaf5713996559ee Mon Sep 17 00:00:00 2001 From: kat Date: Mon, 23 Oct 2023 16:57:02 +0200 Subject: [PATCH] Reduce runtime of MC sampling tests (#585) * samples 10000000 -> 100000 --- .../test_quad/test_quadproblems_gaussian.py | 4 ++-- .../test_quadproblems_gaussian_cases.py | 18 +++++++-------- .../test_quad/test_quadproblems_uniform.py | 2 +- .../test_quadproblems_uniform_cases.py | 22 +++++++++---------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/tests/test_problems/test_zoo/test_quad/test_quadproblems_gaussian.py b/tests/test_problems/test_zoo/test_quad/test_quadproblems_gaussian.py index 6d8139287..7e0a4829f 100644 --- a/tests/test_problems/test_zoo/test_quad/test_quadproblems_gaussian.py +++ b/tests/test_problems/test_zoo/test_quad/test_quadproblems_gaussian.py @@ -179,7 +179,7 @@ def test_gaussian_quadprob(quadprob: QuadratureProblem, rtol: float): The former should be an approximation of the latter. """ # Number of Monte Carlo samples for the test - n = 10000000 + n = 100000 # generate some normally distributed points from N(0, 1) rng = np.random.default_rng(0) @@ -222,7 +222,7 @@ def test_sum_polynomials( """ # Number of Monte Carlo samples for the test - n = 10000000 + n = 100000 quadprob = sum_polynomials(dim, a, b, var) diff --git a/tests/test_problems/test_zoo/test_quad/test_quadproblems_gaussian_cases.py b/tests/test_problems/test_zoo/test_quad/test_quadproblems_gaussian_cases.py index 4061684d4..f0efe21ab 100644 --- a/tests/test_problems/test_zoo/test_quad/test_quadproblems_gaussian_cases.py +++ b/tests/test_problems/test_zoo/test_quad/test_quadproblems_gaussian_cases.py @@ -34,7 +34,7 @@ def case_genz_continuous(self, dim, a, u): quadprob = uniform_to_gaussian_quadprob( genz_continuous(dim=dim, a=a_vec, u=u_vec) ) - rtol = 1e-2 + rtol = 5e-2 return quadprob, rtol @pytest.mark.parametrize("a, u, dim", genz_params) @@ -44,7 +44,7 @@ def case_genz_cornerpeak(self, dim, a, u): quadprob = uniform_to_gaussian_quadprob( genz_cornerpeak(dim=dim, a=a_vec, u=u_vec) ) - rtol = 1e-2 + rtol = 5e-2 return quadprob, rtol @pytest.mark.parametrize("a, u, dim", genz_params) @@ -54,7 +54,7 @@ def case_genz_discontinuous(self, dim, a, u): quadprob = uniform_to_gaussian_quadprob( genz_discontinuous(dim=dim, a=a_vec, u=u_vec) ) - rtol = 1e-2 + rtol = 5e-2 return quadprob, rtol @pytest.mark.parametrize("a, u, dim", genz_params) @@ -64,7 +64,7 @@ def case_genz_gaussian(self, dim, a, u): quadprob = uniform_to_gaussian_quadprob( genz_gaussian(dim=dim, a=a_vec, u=u_vec) ) - rtol = 1e-2 + rtol = 6e-2 return quadprob, rtol @pytest.mark.parametrize("a, u, dim", genz_params) @@ -74,7 +74,7 @@ def case_genz_oscillatory(self, dim, a, u): quadprob = uniform_to_gaussian_quadprob( genz_oscillatory(dim=dim, a=a_vec, u=u_vec) ) - rtol = 9e-2 + rtol = 2. return quadprob, rtol @pytest.mark.parametrize("a, u, dim", genz_params) @@ -84,7 +84,7 @@ def case_genz_productpeak(self, dim, a, u): quadprob = uniform_to_gaussian_quadprob( genz_productpeak(dim=dim, a=a_vec, u=u_vec) ) - rtol = 1e-2 + rtol = 5e-2 return quadprob, rtol @@ -112,19 +112,19 @@ class OtherIntegrandsGaussianCases: @pytest.mark.parametrize("dim", dim_params) def case_bratley1992(self, dim): quadprob = uniform_to_gaussian_quadprob(bratley1992(dim=dim)) - rtol = 1e-3 + rtol = 5e-3 return quadprob, rtol @pytest.mark.parametrize("dim", dim_params) def case_roos_arnold(self, dim): quadprob = uniform_to_gaussian_quadprob(roos_arnold(dim=dim)) - rtol = 1e-3 + rtol = 5e-3 return quadprob, rtol @pytest.mark.parametrize("dim", dim_params) def case_gfunction(self, dim): quadprob = uniform_to_gaussian_quadprob(gfunction(dim=dim)) - rtol = 1e-3 + rtol = 5e-3 return quadprob, rtol @pytest.mark.parametrize("dim", dim_params) diff --git a/tests/test_problems/test_zoo/test_quad/test_quadproblems_uniform.py b/tests/test_problems/test_zoo/test_quad/test_quadproblems_uniform.py index 424959796..2d514e0bb 100644 --- a/tests/test_problems/test_zoo/test_quad/test_quadproblems_uniform.py +++ b/tests/test_problems/test_zoo/test_quad/test_quadproblems_uniform.py @@ -116,7 +116,7 @@ def test_quadprob_uniform_with_mc(quadprob, rtol): """ # Number of Monte Carlo samples for the test - n = 10000000 + n = 100000 # generate some uniformly distributed points from [0, 1] rng = np.random.default_rng(0) diff --git a/tests/test_problems/test_zoo/test_quad/test_quadproblems_uniform_cases.py b/tests/test_problems/test_zoo/test_quad/test_quadproblems_uniform_cases.py index ec40e094f..0f8c1050e 100644 --- a/tests/test_problems/test_zoo/test_quad/test_quadproblems_uniform_cases.py +++ b/tests/test_problems/test_zoo/test_quad/test_quadproblems_uniform_cases.py @@ -32,7 +32,7 @@ def case_genz_continuous(self, dim, a, u): a_vec = np.repeat(a, dim) if a is not None else None u_vec = np.repeat(u, dim) if u is not None else None quadprob = genz_continuous(dim=dim, a=a_vec, u=u_vec) - rtol = 1e-3 + rtol = 5e-2 return quadprob, rtol @pytest.mark.parametrize("a, u, dim", genz_params) @@ -40,7 +40,7 @@ def case_genz_cornerpeak(self, dim, a, u): a_vec = np.repeat(a, dim) if a is not None else None u_vec = np.repeat(u, dim) if u is not None else None quadprob = genz_cornerpeak(dim=dim, a=a_vec, u=u_vec) - rtol = 1e-2 + rtol = 5e-2 return quadprob, rtol @pytest.mark.parametrize("a, u, dim", genz_params) @@ -48,7 +48,7 @@ def case_genz_discontinuous(self, dim, a, u): a_vec = np.repeat(a, dim) if a is not None else None u_vec = np.repeat(u, dim) if u is not None else None quadprob = genz_discontinuous(dim=dim, a=a_vec, u=u_vec) - rtol = 2e-3 + rtol = 5e-2 return quadprob, rtol @pytest.mark.parametrize("a, u, dim", genz_params) @@ -56,7 +56,7 @@ def case_genz_gaussian(self, dim, a, u): a_vec = np.repeat(a, dim) if a is not None else None u_vec = np.repeat(u, dim) if u is not None else None quadprob = genz_gaussian(dim=dim, a=a_vec, u=u_vec) - rtol = 1e-2 + rtol = 9e-2 return quadprob, rtol @pytest.mark.parametrize("a, u, dim", genz_params) @@ -64,7 +64,7 @@ def case_genz_oscillatory(self, dim, a, u): a_vec = np.repeat(a, dim) if a is not None else None u_vec = np.repeat(u, dim) if u is not None else None quadprob = genz_oscillatory(dim=dim, a=a_vec, u=u_vec) - rtol = 9e-2 + rtol = 5e-1 return quadprob, rtol @pytest.mark.parametrize("a, u, dim", genz_params) @@ -72,7 +72,7 @@ def case_genz_productpeak(self, dim, a, u): a_vec = np.repeat(a, dim) if a is not None else None u_vec = np.repeat(u, dim) if u is not None else None quadprob = genz_productpeak(dim=dim, a=a_vec, u=u_vec) - rtol = 1e-3 + rtol = 5e-2 return quadprob, rtol @@ -83,29 +83,29 @@ class OtherIntegrandsUniformCases: @pytest.mark.parametrize("dim", dim_params) def case_bratley1992(self, dim): quadprob = bratley1992(dim=dim) - rtol = 1e-3 + rtol = 1e-2 return quadprob, rtol @pytest.mark.parametrize("dim", dim_params) def case_roos_arnold(self, dim): quadprob = roos_arnold(dim=dim) - rtol = 1e-3 + rtol = 1e-2 return quadprob, rtol @pytest.mark.parametrize("dim", dim_params) def case_gfunction(self, dim): quadprob = gfunction(dim=dim) - rtol = 1e-3 + rtol = 1e-2 return quadprob, rtol @pytest.mark.parametrize("dim", dim_params) def case_morokoff_caflisch_1(self, dim): quadprob = morokoff_caflisch_1(dim=dim) - rtol = 1e-3 + rtol = 1e-2 return quadprob, rtol @pytest.mark.parametrize("dim", dim_params) def case_morokoff_caflisch_2(self, dim): quadprob = morokoff_caflisch_2(dim=dim) - rtol = 1e-3 + rtol = 1e-2 return quadprob, rtol