Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More updates for 0.7 #54

Merged
merged 2 commits into from
Aug 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/autorange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ Base.Iterators.IteratorSize(::Type{CornerIterator{I}}) where {I<:CartesianIndex{
size(iter::CornerIterator{CartesianIndex{N}}) where {N} = ntuple(d->iter.stop.I[d]-iter.start.I[d]==0 ? 1 : 2, Val(N))::NTuple{N,Int}
length(iter::CornerIterator) = prod(size(iter))

@inline function start(iter::CornerIterator{I}) where I<:CartesianIndex
@inline function Base.iterate(iter::CornerIterator{<:CartesianIndex})
if any(map(>, iter.start.I, iter.stop.I))
return iter.stop+1
return nothing
end
iter.start
iterate(iter, iter.start)
end
@inline function next(iter::CornerIterator{I}, state) where I<:CartesianIndex

@inline function Base.iterate(iter::CornerIterator{I}, state) where I<:CartesianIndex
if state.I[end] > iter.stop.I[end]
return nothing
end
state, I(inc(state.I, iter.start.I, iter.stop.I))
end
@inline done(iter::CornerIterator{I}, state) where {I<:CartesianIndex} = state.I[end] > iter.stop.I[end]

# increment & carry
@inline inc(::Tuple{}, ::Tuple{}, ::Tuple{}) = ()
Expand All @@ -57,6 +60,5 @@ end
end

# 0-d is special-cased to iterate once and only once
start(iter::CornerIterator{I}) where {I<:CartesianIndex{0}} = false
next(iter::CornerIterator{I}, state) where {I<:CartesianIndex{0}} = (iter.start, true)
done(iter::CornerIterator{I}, state) where {I<:CartesianIndex{0}} = state
Base.iterate(iter::CornerIterator{<:CartesianIndex{0}}) = (iter.start, nothing)
Base.iterate(iter::CornerIterator{<:CartesianIndex{0}}, state) = nothing
3 changes: 0 additions & 3 deletions src/warp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,3 @@ function warp(img::AbstractArray, tform, args...)
etp = box_extrapolation(img, args...)
warp(etp, tform)
end

@deprecate warp_new(img::AbstractArray, tform, args...) warp(img, tform, args...)
@deprecate warp_old(img::AbstractArray, tform, args...) warp(img, inv(tform), args...)
18 changes: 9 additions & 9 deletions test/interpolations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ end

etp = @inferred ImageTransformations.box_extrapolation(img)
@test @inferred(ImageTransformations.box_extrapolation(etp)) === etp
@test summary(etp) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Linear()), OnGrid()), Gray{N0f8}(0.0)) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test_broken summary(etp) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Linear()), OnGrid()), Gray{N0f8}(0.0)) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test typeof(etp) <: Interpolations.FilledExtrapolation
@test etp.fillvalue === Gray{N0f8}(0.0)
@test etp.itp.coefs === img
Expand All @@ -61,48 +61,48 @@ end
@test_throws ArgumentError ImageTransformations.box_extrapolation(etp.itp, Constant(), Flat())

etp2 = @inferred ImageTransformations.box_extrapolation(etp.itp)
@test summary(etp2) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Linear()), OnGrid()), Gray{N0f8}(0.0)) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test_skip summary(etp2) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Linear()), OnGrid()), Gray{N0f8}(0.0)) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test typeof(etp2) <: Interpolations.FilledExtrapolation
@test etp2.fillvalue === Gray{N0f8}(0.0)
@test etp2 !== etp
@test etp2.itp === etp.itp

etp2 = @inferred ImageTransformations.box_extrapolation(etp.itp, Flat())
@test summary(etp2) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Linear()), OnGrid()), Flat()) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test_skip summary(etp2) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Linear()), OnGrid()), Flat()) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test typeof(etp2) <: Interpolations.Extrapolation
@test etp2 !== etp
@test etp2.itp === etp.itp

etp = @inferred ImageTransformations.box_extrapolation(img, 1)
@test summary(etp) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Linear()), OnGrid()), Gray{N0f8}(1.0)) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test_skip summary(etp) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Linear()), OnGrid()), Gray{N0f8}(1.0)) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test typeof(etp) <: Interpolations.FilledExtrapolation
@test etp.fillvalue === Gray{N0f8}(1.0)
@test etp.itp.coefs === img

etp = @inferred ImageTransformations.box_extrapolation(img, Flat())
@test @inferred(ImageTransformations.box_extrapolation(etp)) === etp
@test summary(etp) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Linear()), OnGrid()), Flat()) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test_skip summary(etp) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Linear()), OnGrid()), Flat()) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test typeof(etp) <: Interpolations.Extrapolation
@test etp.itp.coefs === img

etp = @inferred ImageTransformations.box_extrapolation(img, Constant())
@test summary(etp) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Constant()), OnGrid()), Gray{N0f8}(0.0)) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test_skip summary(etp) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Constant()), OnGrid()), Gray{N0f8}(0.0)) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test typeof(etp) <: Interpolations.FilledExtrapolation
@test etp.itp.coefs === img

etp = @inferred ImageTransformations.box_extrapolation(img, Constant(), Flat())
@test summary(etp) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Constant()), OnGrid()), Flat()) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test_skip summary(etp) == "2×2 extrapolate(interpolate(::Array{Gray{N0f8},2}, BSpline(Constant()), OnGrid()), Flat()) with element type $(ctqual)Gray{$(fpqual)Normed{UInt8,8}}"
@test typeof(etp) <: Interpolations.Extrapolation
@test etp.itp.coefs === img

imgfloat = Float64.(img)
etp = @inferred ImageTransformations.box_extrapolation(imgfloat, Quadratic(Flat()))
@test typeof(etp) <: Interpolations.FilledExtrapolation
@test summary(etp) == "2×2 extrapolate(interpolate(::Array{Float64,2}, BSpline(Quadratic(Flat())), OnGrid()), NaN) with element type Float64"
@test_skip summary(etp) == "2×2 extrapolate(interpolate(::Array{Float64,2}, BSpline(Quadratic(Flat())), OnGrid()), NaN) with element type Float64"

etp = @inferred ImageTransformations.box_extrapolation(imgfloat, Cubic(Flat()), Flat())
@test typeof(etp) <: Interpolations.Extrapolation
@test summary(etp) == "2×2 extrapolate(interpolate(::Array{Float64,2}, BSpline(Cubic(Flat())), OnGrid()), Flat()) with element type Float64"
@test_skip summary(etp) == "2×2 extrapolate(interpolate(::Array{Float64,2}, BSpline(Cubic(Flat())), OnGrid()), Flat()) with element type Float64"
end

@testset "AxisAlgorithms.A_ldiv_B_md" begin
Expand Down
Loading