Skip to content

Commit

Permalink
add tests for 'nu'
Browse files Browse the repository at this point in the history
  • Loading branch information
espdev committed Jul 19, 2020
1 parent 92f01d8 commit c2ae1ec
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_ndg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

import numpy as np
from scipy.interpolate import NdPPoly
import csaps


Expand Down Expand Up @@ -196,3 +197,22 @@ def test_auto_smooth_2d(ndgrid_2d_data):

assert s.smooth == pytest.approx(smooth_expected)
assert zi == pytest.approx(zi_expected)


@pytest.mark.parametrize('nu', [
(0, 0),
(1, 1),
(2, 2),
])
def test_evaluate_nu(nu: tuple):
x = ([1, 2, 3, 4], [1, 2, 3, 4])
y = np.arange(4 * 4).reshape((4, 4))

ss = csaps.NdGridCubicSmoothingSpline(x, y, smooth=1.0)
y_ss = ss(x, nu=nu)

pp = NdPPoly(ss.spline.c, x)
xx = tuple(np.meshgrid(*x, indexing='ij'))
y_pp = pp(xx, nu=nu)

assert y_ss == pytest.approx(y_pp)
14 changes: 14 additions & 0 deletions tests/test_umv.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,17 @@ def test_cubic_bc_natural():

assert cs.c == pytest.approx(ss.spline.c)
assert y_cs == pytest.approx(y_ss)


@pytest.mark.parametrize('nu', [0, 1, 2])
def test_evaluate_nu(nu):
x = [1, 2, 3, 4]
y = [1, 2, 3, 4]

cs = CubicSpline(x, y)
y_cs = cs(x, nu=nu)

ss = csaps.CubicSmoothingSpline(x, y, smooth=1.0)
y_ss = ss(x, nu=nu)

assert y_ss == pytest.approx(y_cs)

0 comments on commit c2ae1ec

Please sign in to comment.