From ef6048dfcf6bf1312135a614a5060f7481ee26e7 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 7 Dec 2019 18:22:48 -0500 Subject: [PATCH] mjo/interpolation.py: wrap map() calls in list() for python-3.x. There's probably a better way to implement these functions for python-3.x, but this fixes the tests for now. --- mjo/interpolation.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mjo/interpolation.py b/mjo/interpolation.py index 25fb11f..6e0ecb3 100644 --- a/mjo/interpolation.py +++ b/mjo/interpolation.py @@ -86,7 +86,7 @@ def lagrange_polynomial(x, xs, ys): TESTS:: sage: xs = [ -pi/2, -pi/6, 0, pi/6, pi/2 ] - sage: ys = map(sin, xs) + sage: ys = list(map(sin, xs)) sage: L = lagrange_polynomial(x, xs, ys) sage: expected = 27/16*(pi - 6*x)*(pi - 2*x)*(pi + 2*x)*x/pi^4 sage: expected -= 1/8*(pi - 6*x)*(pi - 2*x)*(pi + 6*x)*x/pi^4 @@ -187,15 +187,15 @@ def divided_difference(xs, ys): TESTS:: sage: xs = [0] - sage: ys = map(sin, xs) + sage: ys = list(map(sin, xs)) sage: divided_difference(xs, ys) 0 sage: xs = [0, pi] - sage: ys = map(sin, xs) + sage: ys = list(map(sin, xs)) sage: divided_difference(xs, ys) 0 sage: xs = [0, pi, 2*pi] - sage: ys = map(sin, xs) + sage: ys = list(map(sin, xs)) sage: divided_difference(xs, ys) 0 @@ -240,7 +240,7 @@ def newton_polynomial(x, xs, ys): TESTS:: sage: xs = [ -pi/2, -pi/6, 0, pi/6, pi/2 ] - sage: ys = map(sin, xs) + sage: ys = list(map(sin, xs)) sage: L = lagrange_polynomial(x, xs, ys) sage: N = newton_polynomial(x, xs, ys) sage: bool(N == L) @@ -325,8 +325,8 @@ def hermite_interpolant(x, xs, ys, y_primes): TESTS:: sage: xs = [ 0, pi/6, pi/2 ] - sage: ys = map(sin, xs) - sage: y_primes = map(cos, xs) + sage: ys = list(map(sin, xs)) + sage: y_primes = list(map(cos, xs)) sage: H = hermite_interpolant(x, xs, ys, y_primes) sage: expected = -27/4*(pi - 6*x)*(pi - 2*x)^2*sqrt(3)*x^2/pi^4 sage: expected += (5*(pi - 2*x)/pi + 1)*(pi - 6*x)^2*x^2/pi^4 -- 2.44.2