aboutsummaryrefslogtreecommitdiff
path: root/vquad/test
diff options
context:
space:
mode:
authorChristoph Groth <christoph.groth@cea.fr>2018-02-22 16:51:29 +0100
committerChristoph Groth <christoph.groth@cea.fr>2018-02-28 21:01:31 +0100
commit2f95f2f991956abac93cf6b273b1628fbad22f09 (patch)
tree2434455ec919f338a0421ce83d9703e747f9c5d1 /vquad/test
parent581bad7324c4c1164ba4adec69c7b11b0e25fb7e (diff)
implement evaluation of the interpolated integrand
Diffstat (limited to 'vquad/test')
-rw-r--r--vquad/test/test_core.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/vquad/test/test_core.py b/vquad/test/test_core.py
index 648a445..46fd823 100644
--- a/vquad/test/test_core.py
+++ b/vquad/test/test_core.py
@@ -1,10 +1,11 @@
-# Copyright 2017 Christoph Groth (CEA).
+# Copyright 2017, 2018 Christoph Groth (CEA).
#
# This file is part of Vquad. It is subject to the license terms in the file
# LICENSE.rst found in the top-level directory of this distribution.
import numpy as np
from numpy.testing import assert_allclose
+from pytest import raises
from .. import core
@@ -46,7 +47,7 @@ def f_one_with_nan(x):
return result
-def test_downdate(level=3):
+def test_coeffs(level=3):
vals = np.abs(core.tbls.nodes[level])
vals[1::2] = np.nan
c_downdated = core._calc_coeffs(vals, level)
@@ -54,8 +55,10 @@ def test_downdate(level=3):
level -= 1
vals = np.abs(core.tbls.nodes[level])
c = core._calc_coeffs(vals, level)
+ assert_allclose(c_downdated[:len(c)], c, rtol=0, atol=1e-12)
- assert_allclose(c_downdated[:len(c)], c, rtol=0, atol=1e-9)
+ vals_from_c = core._eval_legendre(c, core.tbls.nodes[level])
+ assert_allclose(vals_from_c, vals, rtol=0, atol=1e-15)
def test_integration():
@@ -90,6 +93,21 @@ def test_integration():
np.seterr(**old_settings)
+def test_interpolation():
+ vquad = core.Vquad(f24, 0, 3)
+ vquad.improve_until(1e-6)
+
+ rng = np.random.RandomState(123)
+ x = np.linspace(0, 3, 100)
+ rng.shuffle(x)
+
+ for x in [x, 1.23, [[2, 0], [1, 2]], [], [[]]]:
+ assert_allclose(vquad(x), f24(x))
+
+ for x in [-1e-100, 3.0001, 1e100, [1, 2, -1e50]]:
+ raises(ValueError, vquad, x)
+
+
def test_analytic(n=200):
def f(x):
return f63(x, alpha, beta)