Skip to content

Commit

Permalink
Merge pull request #80 from Evizero/jc/ci
Browse files Browse the repository at this point in the history
[maintenance] deprecation fix, inference fix, and compat update
  • Loading branch information
johnnychen94 authored May 17, 2021
2 parents 121b70d + 817aa56 commit 9069091
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 61 deletions.
9 changes: 5 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,24 @@ ComputationalResources = "0.3"
CoordinateTransformations = "0.5, 0.6"
FileIO = "1"
IdentityRanges = "0.3"
ImageCore = "0.8.1"
ImageCore = "0.8.1, 0.9"
ImageFiltering = "0.4, 0.5, 0.6"
ImageTransformations = "0.5, 0.6, 0.7, 0.8"
Interpolations = "0.8, 0.9, 0.10, 0.11, 0.12"
Interpolations = "0.8, 0.9, 0.10, 0.11, 0.12, 0.13"
MLDataPattern = "0.4, 0.5"
OffsetArrays = "0.8, 0.9, 0.10, 0.11, 1"
Rotations = "0.7, 0.8, 0.9, 0.10, 0.11, 0.12, 0.13, 1"
StaticArrays = "0.8, 0.9, 0.10, 0.11, 0.12"
StaticArrays = "0.8, 0.9, 0.10, 0.11, 0.12, 1"
julia = "1"

[extras]
ImageDistances = "51556ac3-7006-55f5-8cb3-34580c88182d"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TestImages = "5e47fb64-e119-507b-a336-dd2b206d9990"

[targets]
test = ["ImageDistances", "ImageMagick", "ReferenceTests", "Statistics", "TestImages", "Test"]
test = ["ImageDistances", "ImageMagick", "Random", "ReferenceTests", "Statistics", "TestImages", "Test"]
4 changes: 2 additions & 2 deletions src/operations/mapfun.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ end
function applyeager(op::AggregateThenMapFun, img::AbstractArray, param)
# promote the result to float type because `aggfun` might not widely support `Gray{N0f8}`/`N0f8` types well
# e.g, type instability in https://github.com/JuliaGraphics/ColorVectorSpace.jl/issues/134
agg = op.aggfun(of_eltype(floattype(eltype(img)), img))
agg = convert(floattype(eltype(img)), op.aggfun(img))
plain_array(map(x -> op.mapfun(x, agg), img))
end

function applylazy(op::AggregateThenMapFun, img::AbstractArray, param)
agg = op.aggfun(of_eltype(floattype(eltype(img)), img))
agg = convert(floattype(eltype(img)), op.aggfun(img))
mappedarray(x -> op.mapfun(x, agg), img)
end

Expand Down
4 changes: 2 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ end
Return a memory contiguous array for better performance.
Data copy only happens when necessary. For example, views returned by `view`,
`permuteddimsview` are such cases.
`PermutedDimsArray` are such cases.
See also: [`plain_array`](@ref), [`plain_axes`](@ref)
"""
Expand Down Expand Up @@ -63,7 +63,7 @@ Return a memory contiguous plain array for better performance.
A plain array is either an `Array` or a `StaticArray`.
Data copy only happens when necessary. For example, views returned by `view`,
`permuteddimsview` are such cases.
`PermutedDimsArray` are such cases.
See also: [`contiguous`](@ref), [`plain_axes`](@ref)
"""
Expand Down
2 changes: 1 addition & 1 deletion test/operations/tst_dims.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
@testset "lazy" begin
@test Augmentor.supports_lazy(PermuteDims) === true
@test @inferred(Augmentor.supports_lazy(typeof(PermuteDims(2,1)))) === true
f = (img) -> permuteddimsview(img, (2,1))
f = (img) -> PermutedDimsArray(img, (2,1))
imgs = [
(rect),
(Augmentor.prepareaffine(rect)),
Expand Down
4 changes: 2 additions & 2 deletions test/operations/tst_either.jl
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ end
@test_throws MethodError Augmentor.applypermute(op, nothing)
v = @inferred Augmentor.applylazy(op, rect)
@test v === @inferred(Augmentor.applypermute(op, rect))
@test v === view(permuteddimsview(rect,(2,1)),3:-1:1,1:1:2)
@test v === view(PermutedDimsArray(rect,(2,1)),3:-1:1,1:1:2)
@test v == rotl90(rect)
@test typeof(v) <: SubArray
res1, res2 = @inferred Augmentor.applylazy(op, (square2, rect))
Expand All @@ -613,7 +613,7 @@ end
@test_throws MethodError Augmentor.applypermute(op, nothing)
v = @inferred Augmentor.applylazy(op, rect)
@test v === @inferred(Augmentor.applypermute(op, rect))
@test v === view(permuteddimsview(rect,(2,1)),1:1:3,2:-1:1)
@test v === view(PermutedDimsArray(rect,(2,1)),1:1:3,2:-1:1)
@test v == rotr90(rect)
@test typeof(v) <: SubArray
end
Expand Down
8 changes: 4 additions & 4 deletions test/operations/tst_mapfun.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
end
img = OffsetArray(rgb_rect, -2, -1)
res = @inferred(Augmentor.applyeager(MapFun(x -> x - RGB(.1,.1,.1)), img))
@test res collect(img .- RGB(.1,.1,.1))
@test collect(res) OffsetArrays.no_offset_view(img .- RGB(.1,.1,.1))
@test typeof(res) <: Array{RGB{Float64}}
end
end
Expand Down Expand Up @@ -106,7 +106,7 @@ end
end
img = OffsetArray(rgb_rect, -2, -1)
res = @inferred(Augmentor.applyeager(AggregateThenMapFun(mean, (x,a)->x-a), img))
@test res collect(img .- mean(rgb_rect))
@test res OffsetArrays.no_offset_view(img .- mean(rgb_rect))
@test typeof(res) <: Array
@test eltype(res) <: RGB{<:AbstractFloat} # could be either Float32 / Float64
end
Expand All @@ -124,13 +124,13 @@ end
@test parent(res) === rect
@test res isa ReadonlyMappedArray
res = @inferred(Augmentor.applylazy(AggregateThenMapFun(mean, (x,a)->x-a), rgb_rect))
@test res mappedarray(x->x-mean(rgb_rect), rgb_rect)
@test res collect(eltype(res), mappedarray(x->x-mean(rgb_rect), rgb_rect))
@test parent(res) === rgb_rect
@test typeof(res) <: MappedArrays.ReadonlyMappedArray
@test eltype(res) <: RGB{<:AbstractFloat} # could be either Float32 / Float64
img = OffsetArray(rgb_rect, -2, -1)
res = @inferred(Augmentor.applylazy(AggregateThenMapFun(mean, (x,a)->x-a), img))
@test res mappedarray(x->x-mean(rgb_rect), img)
@test res collect(eltype(res), mappedarray(x->x-mean(rgb_rect), img))
@test parent(res) === img
@test typeof(res) <: MappedArrays.ReadonlyMappedArray
@test eltype(res) <: RGB{<:AbstractFloat} # could be either Float32 / Float64
Expand Down
4 changes: 4 additions & 0 deletions test/operations/tst_resize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
@test wv == imresize(square, 2, 3)
end
@testset "multiple images" begin
Random.seed!(0) # otherwise, it would introduce numerical instability after interpolation
square = Gray{N0f8}[0.1 0.2 0.3; 0.4 0.5 0.6; 0.7 0.6 0.9]
square2 = rand(Gray{N0f8}, 4, 4)
wv1, wv2 = @inferred Augmentor.applylazy(Resize(2,3), (square, square2))
@test typeof(wv1) <: SubArray
@test typeof(wv1.indices) <: Tuple{Vararg{IdentityRange}}
Expand All @@ -119,6 +122,7 @@
@test typeof(parent(wv2)) <: InvWarpedView
@test typeof(parent(parent(wv2))) <: Interpolations.Extrapolation
@test parent(parent(wv2)).itp.coefs === square2
# Interpolation might introduce numerical instability
@test wv2 == imresize(square2, 2, 3)
end
end
Expand Down
12 changes: 6 additions & 6 deletions test/operations/tst_rotation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
@testset "lazy" begin
@test Augmentor.supports_lazy(Rotate90) === true
v = @inferred Augmentor.applylazy(Rotate90(), rect)
@test v === view(permuteddimsview(rect, (2,1)), 3:-1:1, 1:1:2)
@test v === view(PermutedDimsArray(rect, (2,1)), 3:-1:1, 1:1:2)
@test v == rotl90(rect)
@test typeof(v) <: SubArray
v = @inferred Augmentor.applylazy(Rotate90(), view(square,1:2,1:3))
@test v === view(permuteddimsview(square, (2,1)), 3:-1:1, 1:1:2)
@test v === view(PermutedDimsArray(square, (2,1)), 3:-1:1, 1:1:2)
@test v == rotl90(rect)
@test typeof(v) <: SubArray
wv = @inferred Augmentor.applylazy(Rotate90(), Augmentor.prepareaffine(square))
Expand All @@ -77,7 +77,7 @@
@testset "permute" begin
@test Augmentor.supports_permute(Rotate90) === true
v = @inferred Augmentor.applypermute(Rotate90(), rect)
@test v === view(permuteddimsview(rect, (2,1)), 3:-1:1, 1:1:2)
@test v === view(PermutedDimsArray(rect, (2,1)), 3:-1:1, 1:1:2)
@test v == rotl90(rect)
@test typeof(v) <: SubArray
v2 = @inferred Augmentor.applypermute(Rotate90(), v)
Expand Down Expand Up @@ -212,11 +212,11 @@ end
@testset "lazy" begin
@test Augmentor.supports_lazy(Rotate270) === true
v = @inferred Augmentor.applylazy(Rotate270(), rect)
@test v === view(permuteddimsview(rect, (2,1)), 1:1:3, 2:-1:1)
@test v === view(PermutedDimsArray(rect, (2,1)), 1:1:3, 2:-1:1)
@test v == rotr90(rect)
@test typeof(v) <: SubArray
v = @inferred Augmentor.applylazy(Rotate270(), view(square,1:2,1:3))
@test v === view(permuteddimsview(square, (2,1)), 1:1:3, 2:-1:1)
@test v === view(PermutedDimsArray(square, (2,1)), 1:1:3, 2:-1:1)
@test v == rotr90(rect)
@test typeof(v) <: SubArray
wv = @inferred Augmentor.applylazy(Rotate270(), Augmentor.prepareaffine(square))
Expand All @@ -233,7 +233,7 @@ end
@testset "permute" begin
@test Augmentor.supports_permute(Rotate270) === true
v = @inferred Augmentor.applypermute(Rotate270(), rect)
@test v === view(permuteddimsview(rect, (2,1)), 1:1:3, 2:-1:1)
@test v === view(PermutedDimsArray(rect, (2,1)), 1:1:3, 2:-1:1)
@test v == rotr90(rect)
@test typeof(v) <: SubArray
v2 = @inferred Augmentor.applypermute(Rotate270(), v)
Expand Down
Loading

0 comments on commit 9069091

Please sign in to comment.