diff --git a/Project.toml b/Project.toml index 8da64001..dc812646 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Interpolations" uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" -version = "0.14.2" +version = "0.14.3" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/src/deprecations.jl b/src/deprecations.jl index e6e8c15e..a4598a21 100644 --- a/src/deprecations.jl +++ b/src/deprecations.jl @@ -64,6 +64,6 @@ replace_linear_line(bc::BoundaryCondition) = bc replace_linear_line(etpflag::Tuple) = replace_linear_line.(etpflag) # Old convenience constructors -@deprecate LinearInterpolation linear_interpolation -@deprecate ConstantInterpolation constant_interpolation -@deprecate CubicSplineInterpolation cubic_spline_interpolation +@deprecate LinearInterpolation(args...; kwargs...) linear_interpolation(args...; kwargs...) +@deprecate ConstantInterpolation(args...; kwargs...) constant_interpolation(args...; kwargs...) +@deprecate CubicSplineInterpolation(args...; kwargs...) cubic_spline_interpolation(args...; kwargs...) diff --git a/test/convenience-constructors.jl b/test/convenience-constructors.jl index e46ec6e6..604dcf5e 100644 --- a/test/convenience-constructors.jl +++ b/test/convenience-constructors.jl @@ -47,6 +47,19 @@ YLEN = convert(Integer, floor((YMAX - YMIN)/ΔY) + 1) @test interp(XMIN + ΔX / 2) ≈ f(XMIN + ΔX / 2) atol=.1 @test_throws BoundsError interp(XMIN - ΔX / 2) @test_throws BoundsError interp(XMAX + ΔX / 2) + + # Check deprecated usage + interp = ConstantInterpolation(xs, A; extrapolation_bc = Throw()) # using convenience constructor + interp_full = extrapolate(scale(interpolate(A, BSpline(Constant())), xs), Throw()) # using full constructor + + @test typeof(interp) == typeof(interp_full) + @test interp(XMIN) ≈ f(XMIN) + @test interp(XMAX) ≈ f(XMAX) + @test interp(XMIN + ΔX) ≈ f(XMIN + ΔX) + @test interp(XMAX - ΔX) ≈ f(XMAX - ΔX) + @test interp(XMIN + ΔX / 2) ≈ f(XMIN + ΔX / 2) atol=.1 + @test_throws BoundsError interp(XMIN - ΔX / 2) + @test_throws BoundsError interp(XMAX + ΔX / 2) end @testset "1d-regular-grids-cubic" begin @@ -64,6 +77,19 @@ YLEN = convert(Integer, floor((YMAX - YMIN)/ΔY) + 1) @test interp(XMIN + ΔX / 2) ≈ f(XMIN + ΔX / 2) atol=.1 @test_throws BoundsError interp(XMIN - ΔX / 2) @test_throws BoundsError interp(XMAX + ΔX / 2) + + # Check deprecated usage + interp = CubicSplineInterpolation(xs, A; extrapolation_bc = Throw()) + interp_full = extrapolate(scale(interpolate(A, BSpline(Cubic(Line(OnGrid())))), xs), Throw()) + + @test typeof(interp) == typeof(interp_full) + @test interp(XMIN) ≈ f(XMIN) + @test interp(XMAX) ≈ f(XMAX) + @test interp(XMIN + ΔX) ≈ f(XMIN + ΔX) + @test interp(XMAX - ΔX) ≈ f(XMAX - ΔX) + @test interp(XMIN + ΔX / 2) ≈ f(XMIN + ΔX / 2) atol=.1 + @test_throws BoundsError interp(XMIN - ΔX / 2) + @test_throws BoundsError interp(XMAX + ΔX / 2) end @testset "1d-irregular-grids" begin @@ -117,6 +143,14 @@ YLEN = convert(Integer, floor((YMAX - YMIN)/ΔY) + 1) @test typeof(extrap) == typeof(extrap_full) @test extrap(x_lower) ≈ A[1] - ΔA_l @test extrap(x_higher) ≈ A[end] + ΔA_h + + # Check deprecated usage + extrap = LinearInterpolation(xs, A, extrapolation_bc = Line()) + extrap_full = extrapolate(scale(interpolate(A, BSpline(Linear())), xs), Line()) + + @test typeof(extrap) == typeof(extrap_full) + @test extrap(x_lower) ≈ A[1] - ΔA_l + @test extrap(x_higher) ≈ A[end] + ΔA_h end end @@ -262,6 +296,14 @@ end @test typeof(extrap) == typeof(extrap_full) @test extrap(x_lower, y_lower) ≈ A[1, 1] - ΔA_l @test extrap(x_higher, y_higher) ≈ A[end, end] + ΔA_h + + # Check deprecated usage + extrap = LinearInterpolation((xs, ys), A, extrapolation_bc = (Line(), Flat())) + extrap_full = extrapolate(scale(interpolate(A, BSpline(Linear())), xs, ys), (Line(), Flat())) + + @test typeof(extrap) == typeof(extrap_full) + @test extrap(x_lower, y_lower) ≈ A[1, 1] - ΔA_l + @test extrap(x_higher, y_higher) ≈ A[end, end] + ΔA_h end @testset "issue #230" begin # at least, I think this is what issue #230 is really about