Skip to content

Commit

Permalink
fix commit "WIP: update 1.0"
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnychen94 committed Dec 17, 2019
1 parent 19aeb9e commit 733e32b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
11 changes: 2 additions & 9 deletions src/distortedview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@ struct DistortedView{T,P<:AbstractMatrix,E<:AbstractExtrapolation,G,D} <: Abstra

function DistortedView(parent::AbstractMatrix{T}, grid::AbstractArray{Float64,3}) where T
@assert size(grid,1) == 2
# to compare two DistortedViews, their `axes` should be the same
parent = plain_axes(parent)
etp = ImageTransformations.box_extrapolation(parent, Flat())
field = ImageTransformations.box_extrapolation(grid, 0.0)
new{T,typeof(parent),typeof(etp),typeof(grid),typeof(field)}(parent, etp, grid, field)
end
end

# TODO: update1.0: check if these two methods are unnecessary
function DistortedView(A::Union{OffsetArray, SubArray},
grid::AbstractArray{Float64, 3})
DistortedView(parent(A), grid)
end
function DistortedView(A::InvWarpedView, grid::AbstractArray{Float64, 3})
DistortedView(collect(A), grid)
end

Base.parent(A::DistortedView) = A.parent
Base.size(A::DistortedView) = map(length, axes(A))
Base.axes(A::DistortedView) = axes(A.parent)
Expand Down
2 changes: 2 additions & 0 deletions src/operation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ for FUN in (:applyeager, :applylazy, :applypermute,
end

function applyeager(op::Operation, img::AbstractArray, param)
# TODO: we don't need wrappers for eager mode, so we might want to
# add plain_array to it as well for the sake of simplicity
contiguous(applylazy(op, img, param))
end

Expand Down
11 changes: 9 additions & 2 deletions test/operations/tst_distortions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,15 @@
res = @inferred(Augmentor.applylazy(ElasticDistortion(4,4), img))
@test size(res) == size(rect)
@test typeof(res) <: Augmentor.DistortedView{eltype(rect)}
# @test parent(res) == img # TODO: update1.0:
# @test parent(res) === img # TODO: update1.0:
@test parent(res) == rect
# wapper type may change, but storage data isn't copied
if img isa InvWarpedView
@test parent(parent(res)) === img
elseif img isa SubArray
@test parent(parent(res)) === rect
else
@test parent(parent(res)) === rect
end
end
end
@testset "multiple images" begin
Expand Down
2 changes: 1 addition & 1 deletion test/tst_operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ ops = (Rotate180(), ElasticDistortion(5))
@test_throws MethodError Augmentor.unroll_applyaffine(ops, square)
v = @inferred Augmentor.unroll_applylazy(ops, square)
@test v isa Augmentor.DistortedView
@test_broken parent(v) === view(square, 3:-1:1, 3:-1:1) # TODO: update1.0
@test parent(v) === view(square, 3:-1:1, 3:-1:1)
end

ops = (Rotate180(), CropSize(2,2))
Expand Down

0 comments on commit 733e32b

Please sign in to comment.