Skip to content

Commit

Permalink
TST: tests for shepard interpolation values.
Browse files Browse the repository at this point in the history
  • Loading branch information
phmbressan committed Nov 17, 2023
1 parent 404d152 commit f0f0a71
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,22 @@ def test_multivariable_function_plot(mock_show):

# Assert plot
assert func.plot() == None


@pytest.mark.parametrize(
"x,y,z_expected",
[
(1, 0, 0),
(0, 1, 0),
(0, 0, 1),
(0.5, 0.5, 1 / 3),
(0.25, 0.25, 25 / (25 + 2 * 5**0.5)),
],
)
def test_shepard_interpolation(x, y, z_expected):
"""Test the shepard interpolation method of the Function class."""
# Test plane x + y + z = 1
source = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
func = Function(source=source, inputs=["x", "y"], outputs=["z"])
z = func(x, y)
assert np.isclose(z, z_expected, atol=1e-8)

0 comments on commit f0f0a71

Please sign in to comment.