Skip to content

Commit

Permalink
Fix #507 deprecation of of camel case convenience constructors (#508)
Browse files Browse the repository at this point in the history
* Fix #507 deprecation of of camel case convenience constructors

* Bump version to 0.14.3
  • Loading branch information
mkitti authored Aug 1, 2022
1 parent c480a89 commit 62bfe77
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions src/deprecations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
42 changes: 42 additions & 0 deletions test/convenience-constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

2 comments on commit 62bfe77

@mkitti
Copy link
Collaborator Author

@mkitti mkitti commented on 62bfe77 Aug 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/65457

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.14.3 -m "<description of version>" 62bfe779690d718db96ce8f1017a0447b05d8faf
git push origin v0.14.3

Please sign in to comment.