Skip to content

Commit 62bfe77

Browse files
authored
Fix #507 deprecation of of camel case convenience constructors (#508)
* Fix #507 deprecation of of camel case convenience constructors * Bump version to 0.14.3
1 parent c480a89 commit 62bfe77

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Interpolations"
22
uuid = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
3-
version = "0.14.2"
3+
version = "0.14.3"
44

55
[deps]
66
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

src/deprecations.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ replace_linear_line(bc::BoundaryCondition) = bc
6464
replace_linear_line(etpflag::Tuple) = replace_linear_line.(etpflag)
6565

6666
# Old convenience constructors
67-
@deprecate LinearInterpolation linear_interpolation
68-
@deprecate ConstantInterpolation constant_interpolation
69-
@deprecate CubicSplineInterpolation cubic_spline_interpolation
67+
@deprecate LinearInterpolation(args...; kwargs...) linear_interpolation(args...; kwargs...)
68+
@deprecate ConstantInterpolation(args...; kwargs...) constant_interpolation(args...; kwargs...)
69+
@deprecate CubicSplineInterpolation(args...; kwargs...) cubic_spline_interpolation(args...; kwargs...)

test/convenience-constructors.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ YLEN = convert(Integer, floor((YMAX - YMIN)/ΔY) + 1)
4747
@test interp(XMIN + ΔX / 2) f(XMIN + ΔX / 2) atol=.1
4848
@test_throws BoundsError interp(XMIN - ΔX / 2)
4949
@test_throws BoundsError interp(XMAX + ΔX / 2)
50+
51+
# Check deprecated usage
52+
interp = ConstantInterpolation(xs, A; extrapolation_bc = Throw()) # using convenience constructor
53+
interp_full = extrapolate(scale(interpolate(A, BSpline(Constant())), xs), Throw()) # using full constructor
54+
55+
@test typeof(interp) == typeof(interp_full)
56+
@test interp(XMIN) f(XMIN)
57+
@test interp(XMAX) f(XMAX)
58+
@test interp(XMIN + ΔX) f(XMIN + ΔX)
59+
@test interp(XMAX - ΔX) f(XMAX - ΔX)
60+
@test interp(XMIN + ΔX / 2) f(XMIN + ΔX / 2) atol=.1
61+
@test_throws BoundsError interp(XMIN - ΔX / 2)
62+
@test_throws BoundsError interp(XMAX + ΔX / 2)
5063
end
5164

5265
@testset "1d-regular-grids-cubic" begin
@@ -64,6 +77,19 @@ YLEN = convert(Integer, floor((YMAX - YMIN)/ΔY) + 1)
6477
@test interp(XMIN + ΔX / 2) f(XMIN + ΔX / 2) atol=.1
6578
@test_throws BoundsError interp(XMIN - ΔX / 2)
6679
@test_throws BoundsError interp(XMAX + ΔX / 2)
80+
81+
# Check deprecated usage
82+
interp = CubicSplineInterpolation(xs, A; extrapolation_bc = Throw())
83+
interp_full = extrapolate(scale(interpolate(A, BSpline(Cubic(Line(OnGrid())))), xs), Throw())
84+
85+
@test typeof(interp) == typeof(interp_full)
86+
@test interp(XMIN) f(XMIN)
87+
@test interp(XMAX) f(XMAX)
88+
@test interp(XMIN + ΔX) f(XMIN + ΔX)
89+
@test interp(XMAX - ΔX) f(XMAX - ΔX)
90+
@test interp(XMIN + ΔX / 2) f(XMIN + ΔX / 2) atol=.1
91+
@test_throws BoundsError interp(XMIN - ΔX / 2)
92+
@test_throws BoundsError interp(XMAX + ΔX / 2)
6793
end
6894

6995
@testset "1d-irregular-grids" begin
@@ -117,6 +143,14 @@ YLEN = convert(Integer, floor((YMAX - YMIN)/ΔY) + 1)
117143
@test typeof(extrap) == typeof(extrap_full)
118144
@test extrap(x_lower) A[1] - ΔA_l
119145
@test extrap(x_higher) A[end] + ΔA_h
146+
147+
# Check deprecated usage
148+
extrap = LinearInterpolation(xs, A, extrapolation_bc = Line())
149+
extrap_full = extrapolate(scale(interpolate(A, BSpline(Linear())), xs), Line())
150+
151+
@test typeof(extrap) == typeof(extrap_full)
152+
@test extrap(x_lower) A[1] - ΔA_l
153+
@test extrap(x_higher) A[end] + ΔA_h
120154
end
121155
end
122156

@@ -262,6 +296,14 @@ end
262296
@test typeof(extrap) == typeof(extrap_full)
263297
@test extrap(x_lower, y_lower) A[1, 1] - ΔA_l
264298
@test extrap(x_higher, y_higher) A[end, end] + ΔA_h
299+
300+
# Check deprecated usage
301+
extrap = LinearInterpolation((xs, ys), A, extrapolation_bc = (Line(), Flat()))
302+
extrap_full = extrapolate(scale(interpolate(A, BSpline(Linear())), xs, ys), (Line(), Flat()))
303+
304+
@test typeof(extrap) == typeof(extrap_full)
305+
@test extrap(x_lower, y_lower) A[1, 1] - ΔA_l
306+
@test extrap(x_higher, y_higher) A[end, end] + ΔA_h
265307
end
266308

267309
@testset "issue #230" begin # at least, I think this is what issue #230 is really about

0 commit comments

Comments
 (0)