Skip to content

Commit

Permalink
removed OffsetArrays and ImageTransformations patches
Browse files Browse the repository at this point in the history
  • Loading branch information
merl-dev committed Feb 3, 2019
1 parent fb57ce2 commit 6516b85
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 45 deletions.
2 changes: 1 addition & 1 deletion docs/exampleweaver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function weave_notebook(scriptname; overwrite=false, execute=true)
if execute
sleep(1)
@info "executing and overwrite notebook \"$(name*".ipynb")\""
run(`jupyter-nbconvert --ExecutePreprocessor.timeout=-1 --to notebook --execute $(abspath(jppath)) --output $(name * ".ipynb")`)
run(`jupyter nbconvert --ExecutePreprocessor.timeout=-1 --to notebook --execute $(abspath(jppath)) --output $(name * ".ipynb")`)
end
# cleanup temporary files
rm(processed_scriptpath)
Expand Down
40 changes: 3 additions & 37 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,41 +177,7 @@ function _2dborder!(A::AbstractArray{T,3}, val::T) where T
A
end

import ImageTransformations: restrict_indices
#import ImageTransformations: restrict_indices

restrict_indices(r::Base.IdentityUnitRange) =
restrict_indices(r.indices)

# from latest OffsetArrays master
# see https://discourse.julialang.org/t/lift-and-wrap-array-with-custom-indexes/19436/11
# https://github.com/JuliaArrays/OffsetArrays.jl/pull/66
# Remove this when new release tagged
"""
no_offset_view(A)
Return an `AbstractArray` that shares structure and has the same type and size as the
argument, but has 1-based indexing. May just return the argument when applicable. Not
exported.
The default implementation uses `OffsetArrays`, but other types should use something more
specific to remove a level of indirection when applicable.
```jldoctest
julia> O = OffsetArray(A, 0:1, -1:1)
OffsetArray(::Array{Int64,2}, 0:1, -1:1) with eltype Int64 with indices 0:1×-1:1:
1 3 5
2 4 6
julia> OffsetArrays.no_offset_view(O)[1,1] = -9
-9
julia> A
2×3 Array{Int64,2}:
-9 3 5
2 4 6
```
"""
function no_offset_view(A::AbstractArray)
if Base.has_offset_axes(A)
OffsetArray(A, map(r->1-first(r), axes(A)))
else
A
end
end

no_offset_view(A::OffsetArray) = no_offset_view(parent(A))
# ImageTransformations.restrict_indices(r::Base.IdentityUnitRange) =
# restrict_indices(r.indices)
3 changes: 1 addition & 2 deletions test/operations/tst_channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
(view(rect, IdentityRange(1:2), IdentityRange(1:3)), f1),
(rgb_rect, f2),
(Augmentor.prepareaffine(rgb_rect), f2),
#(OffsetArrays.no_offset_view(OffsetArray(rgb_rect, -2, -1)), f2),
(Augmentor.no_offset_view(OffsetArray(rgb_rect, -2, -1)), f2),
(OffsetArrays.no_offset_view(OffsetArray(rgb_rect, -2, -1)), f2),
(view(rgb_rect, IdentityRange(1:2), IdentityRange(1:3)), f2),
]
@testset "single image" begin
Expand Down
3 changes: 1 addition & 2 deletions test/operations/tst_distortions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@
imgs = [
(rect),
(Augmentor.prepareaffine(rect)),
#(OffsetArrays.no_offset_view(OffsetArray(rect, -2, -1))),
(Augmentor.no_offset_view(OffsetArray(rect, -2, -1))),
(OffsetArrays.no_offset_view(OffsetArray(rect, -2, -1))),
(view(rect, IdentityRange(1:2), IdentityRange(1:3))),
]
@testset "eager" begin
Expand Down
2 changes: 1 addition & 1 deletion test/tst_augment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ ops = (Rotate(45), CropSize(200,200), Zoom(1.1), ConvertEltype(RGB{Float64}),
# however:
@test size(collect(wv1)) === size(img)
# so (not sure if this is desired behaviour):
@test collect(wv1) Augmentor.no_offset_view(img)
@test collect(wv1) OffsetArrays.no_offset_view(img)
@test_reference "reference/rot45_crop_zoom_convert.txt" wv2
end

Expand Down
2 changes: 1 addition & 1 deletion test/tst_distortedview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ end
@test summary(dv) == "512×512 Augmentor.DistortedView(::Array{Gray{N0f8},2}, ::Array{Float64,3} as 3×3 vector field) with eltype Gray{Normed{UInt8,8}}"
@test_reference "reference/distort_static.txt" dv

camerao = Augmentor.no_offset_view(OffsetArray(camera, (-5,-10)))
camerao = OffsetArrays.no_offset_view(OffsetArray(camera, (-5,-10)))
dv2 = @inferred Augmentor.DistortedView(camerao, A)
@test size(dv2) == size(camera)
@test eltype(dv2) == eltype(camera)
Expand Down
2 changes: 1 addition & 1 deletion test/tst_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
let p = permuteddimsview(Ao, (2,1))
pc = @inferred(Augmentor.maybe_copy(p))
#@test pc == Ao'
@test pc == Augmentor.no_offset_view(Ao')
@test pc == OffsetArrays.no_offset_view(Ao')
@test typeof(pc) <: Array
end
let p = view(permuteddimsview(A, (2,1)), IdentityRange(2:3), IdentityRange(1:2))
Expand Down

0 comments on commit 6516b85

Please sign in to comment.