Created
September 10, 2018 22:47
-
-
Save mwhudson/b4977b2adf6faf25c9230a8694783ced to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Building, see build.log... | |
Build OK (0:00:03.504590 elapsed) | |
============================= test session starts ============================== | |
platform linux -- Python 3.6.6+, pytest-3.6.4, py-1.5.4, pluggy-0.6.0 -- /usr/bin/python3.6 | |
cachedir: ../../../../../.pytest_cache | |
rootdir: /root/scipy, inifile: pytest.ini | |
collecting ... collected 1 item | |
scipy/interpolate/tests/test_polyint.py::TestCubicSpline::test_general FAILED [100%] | |
=================================== FAILURES =================================== | |
_________________________ TestCubicSpline.test_general _________________________ | |
self = <scipy.interpolate.tests.test_polyint.TestCubicSpline object at 0xf4b04e8c> | |
def test_general(self): | |
x = np.array([-1, 0, 0.5, 2, 4, 4.5, 5.5, 9]) | |
y = np.array([0, -0.5, 2, 3, 2.5, 1, 1, 0.5]) | |
for n in [2, 3, x.size]: | |
self.check_all_bc(x[:n], y[:n], 0) | |
Y = np.empty((2, n, 2)) | |
Y[0, :, 0] = y[:n] | |
Y[0, :, 1] = y[:n] - 1 | |
Y[1, :, 0] = y[:n] + 2 | |
Y[1, :, 1] = y[:n] + 3 | |
> self.check_all_bc(x[:n], Y, 1) | |
Y = array([[[ 0. , -1. ], | |
[-0.5, -1.5], | |
[ 2. , 1. ]], | |
[[ 2. , 3. ], | |
[ 1.5, 2.5], | |
[ 4. , 5. ]]]) | |
n = 3 | |
self = <scipy.interpolate.tests.test_polyint.TestCubicSpline object at 0xf4b04e8c> | |
x = array([-1. , 0. , 0.5, 2. , 4. , 4.5, 5.5, 9. ]) | |
y = array([ 0. , -0.5, 2. , 3. , 2.5, 1. , 1. , 0.5]) | |
scipy/interpolate/tests/test_polyint.py:576: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
scipy/interpolate/tests/test_polyint.py:558: in check_all_bc | |
self.check_correctness(S, bc, bc) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
S = <scipy.interpolate._cubic.CubicSpline object at 0xf4b1114c> | |
bc_start = 'natural', bc_end = 'natural', tol = 1e-14 | |
@staticmethod | |
def check_correctness(S, bc_start='not-a-knot', bc_end='not-a-knot', | |
tol=1e-14): | |
"""Check that spline coefficients satisfy the continuity and boundary | |
conditions.""" | |
x = S.x | |
c = S.c | |
dx = np.diff(x) | |
dx = dx.reshape([dx.shape[0]] + [1] * (c.ndim - 2)) | |
dxi = dx[:-1] | |
# Check C2 continuity. | |
assert_allclose(c[3, 1:], c[0, :-1] * dxi**3 + c[1, :-1] * dxi**2 + | |
c[2, :-1] * dxi + c[3, :-1], rtol=tol, atol=tol) | |
assert_allclose(c[2, 1:], 3 * c[0, :-1] * dxi**2 + | |
2 * c[1, :-1] * dxi + c[2, :-1], rtol=tol, atol=tol) | |
assert_allclose(c[1, 1:], 3 * c[0, :-1] * dxi + c[1, :-1], | |
rtol=tol, atol=tol) | |
# Check that we found a parabola, the third derivative is 0. | |
if x.size == 3 and bc_start == 'not-a-knot' and bc_end == 'not-a-knot': | |
assert_allclose(c[0], 0, rtol=tol, atol=tol) | |
return | |
# Check periodic boundary conditions. | |
if bc_start == 'periodic': | |
assert_allclose(S(x[0], 0), S(x[-1], 0), rtol=tol, atol=tol) | |
assert_allclose(S(x[0], 1), S(x[-1], 1), rtol=tol, atol=tol) | |
assert_allclose(S(x[0], 2), S(x[-1], 2), rtol=tol, atol=tol) | |
return | |
# Check other boundary conditions. | |
if bc_start == 'not-a-knot': | |
if x.size == 2: | |
slope = (S(x[1]) - S(x[0])) / dx[0] | |
assert_allclose(S(x[0], 1), slope, rtol=tol, atol=tol) | |
else: | |
assert_allclose(c[0, 0], c[0, 1], rtol=tol, atol=tol) | |
elif bc_start == 'clamped': | |
assert_allclose(S(x[0], 1), 0, rtol=tol, atol=tol) | |
elif bc_start == 'natural': | |
assert_allclose(S(x[0], 2), 0, rtol=tol, atol=tol) | |
else: | |
order, value = bc_start | |
assert_allclose(S(x[0], order), value, rtol=tol, atol=tol) | |
if bc_end == 'not-a-knot': | |
if x.size == 2: | |
slope = (S(x[1]) - S(x[0])) / dx[0] | |
assert_allclose(S(x[1], 1), slope, rtol=tol, atol=tol) | |
else: | |
assert_allclose(c[0, -1], c[0, -2], rtol=tol, atol=tol) | |
elif bc_end == 'clamped': | |
assert_allclose(S(x[-1], 1), 0, rtol=tol, atol=tol) | |
elif bc_end == 'natural': | |
> assert_allclose(S(x[-1], 2), 0, rtol=tol, atol=tol) | |
E AssertionError: | |
E Not equal to tolerance rtol=1e-14, atol=1e-14 | |
E | |
E (mismatch 100.0%) | |
E x: array([[-1.065814e-14, -1.065814e-14], | |
E [-1.065814e-14, -1.065814e-14]]) | |
E y: array(0) | |
S = <scipy.interpolate._cubic.CubicSpline object at 0xf4b1114c> | |
bc_end = 'natural' | |
bc_start = 'natural' | |
c = array([[[[ 1.83333333, 1.83333333], | |
[ 1.83333333, 1.83333333]], | |
[[-3.66666667, -3.66666667], | |
... ], | |
[ 2. , 3. ]], | |
[[-0.5 , -1.5 ], | |
[ 1.5 , 2.5 ]]]]) | |
dx = array([[[1. ]], | |
[[0.5]]]) | |
dxi = array([[[1.]]]) | |
tol = 1e-14 | |
x = array([-1. , 0. , 0.5]) | |
scipy/interpolate/tests/test_polyint.py:537: AssertionError | |
=========================== 1 failed in 0.32 seconds =========================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment