Skip to content

Commit

Permalink
Reduce runtime of MC sampling tests (#585)
Browse files Browse the repository at this point in the history
* samples 10000000 -> 100000
  • Loading branch information
kat committed Oct 23, 2023
1 parent 342ea29 commit 4e6fff0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/probnum/problems/zoo/quad/_quadproblems_gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def uniform_to_gaussian_quadprob(
Example
-------
Convert the uniform continuous Genz problem to a Gaussian quadrature problem.
>>> import numpy as np
>>> from probnum.problems.zoo.quad import genz_continuous
>>> gaussian_quadprob = uniform_to_gaussian_quadprob(genz_continuous(1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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.0
return quadprob, rtol

@pytest.mark.parametrize("a, u, dim", genz_params)
Expand All @@ -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


Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,47 +32,47 @@ 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)
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)
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)
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)
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)
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


Expand All @@ -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

0 comments on commit 4e6fff0

Please sign in to comment.