From 442ca575b029c244e7307b502b63d11611dc205b Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 1 Nov 2018 15:10:20 -0400 Subject: [PATCH] mjo/interpolation.py: allow tests to run with PYTHONPATH=".". --- mjo/interpolation.py | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/mjo/interpolation.py b/mjo/interpolation.py index 4be95e2..dc06107 100644 --- a/mjo/interpolation.py +++ b/mjo/interpolation.py @@ -44,6 +44,10 @@ def lagrange_coefficient(k, x, xs): A symbolic expression of one variable. + SETUP:: + + sage: from mjo.interpolation import lagrange_coefficient + TESTS:: sage: xs = [ -pi/2, -pi/6, 0, pi/6, pi/2 ] @@ -75,6 +79,10 @@ def lagrange_polynomial(x, xs, ys): A symbolic expression (polynomial) interpolating each (xs[k], ys[k]). + SETUP:: + + sage: from mjo.interpolation import lagrange_polynomial + TESTS:: sage: xs = [ -pi/2, -pi/6, 0, pi/6, pi/2 ] @@ -111,6 +119,10 @@ def lagrange_interpolate(f, x, xs): A polynomial in ``x`` which interpolates ``f`` at ``xs``. + SETUP:: + + sage: from mjo.interpolation import lagrange_interpolate + EXAMPLES: We're exact on polynomials of degree `n` if we use `n+1` points:: @@ -135,7 +147,11 @@ def divided_difference_coefficients(xs): Assuming some function `f`, compute the coefficients of the divided difference f[xs[0], ..., xs[n]]. - TESTS: + SETUP:: + + sage: from mjo.interpolation import divided_difference_coefficients + + TESTS:: sage: divided_difference_coefficients([0]) [1] @@ -166,6 +182,10 @@ def divided_difference(xs, ys): The (possibly symbolic) divided difference function. + SETUP:: + + sage: from mjo.interpolation import divided_difference + TESTS:: sage: xs = [0] @@ -215,7 +235,11 @@ def newton_polynomial(x, xs, ys): A symbolic expression. - TESTS: + SETUP:: + + sage: from mjo.interpolation import lagrange_polynomial, newton_polynomial + + TESTS:: sage: xs = [ -pi/2, -pi/6, 0, pi/6, pi/2 ] sage: ys = map(sin, xs) @@ -304,7 +328,11 @@ def hermite_interpolant(x, xs, ys, y_primes): A symbolic expression. - TESTS: + SETUP:: + + sage: from mjo.interpolation import hermite_interpolant + + TESTS:: sage: xs = [ 0, pi/6, pi/2 ] sage: ys = map(sin, xs) -- 2.44.2