-
Notifications
You must be signed in to change notification settings - Fork 45
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
update codebase to 1.0 and 1.x (continue #27) #31
Conversation
@Evizero could you enable Auto Cancellation of the previous build in travis? |
It looks enabled already |
Only meta operations such as Either, Pipeline doesn't have Agumentor prefix
* maybe_copy doesn't explain its usage * replace Slice by OffsetArrays.IdentityUnitRange JuliaArrays/OffsetArrays.jl#62
detect some type instable test cases, only the outmost wrapper is instable here
test/operations/tst_either.jl
Outdated
@@ -117,68 +117,68 @@ end | |||
@test Augmentor.supports_view(op) === false | |||
@test Augmentor.supports_stepview(op) === false | |||
@test Augmentor.supports_permute(op) === false | |||
@test @inferred(Augmentor.applyeager(op, img)) == rotl90(rect) | |||
@test typeof(Augmentor.applyeager(op, img)) <: OffsetArray | |||
@test @inferred(Augmentor.applyeager(op, img, Augmentor.randparam(op, img))) == rotl90(rect) # TODO: update 1.2: type instable if remove Augmentor.randparam |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type instability is detected here for Julia 1.2; the lucky part is that only the out-most wrapper is affected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it randparam
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable, I'll check that; not very familiar with this kind of issue at present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that the following part doesn't work anymore
Augmentor.jl/src/operations/either.jl
Lines 175 to 181 in 6055db7
# To preserve type stability of "applyeager", always promote | |
# arrays to offset arrays | |
@inline _offsetarray(A::Array) = OffsetArray(A, 0, 0) | |
@inline _offsetarray(A::OffsetArray) = A | |
function applyeager(op::Either, img::AbstractArray, idx) | |
_offsetarray(applyeager(op.operations[idx], img)) | |
end |
a typical error is like
ERROR: return type OffsetArray{Gray{Normed{UInt8,8}},2,Array{Gray{Normed{UInt8,8}},2}} does not match inferred return type OffsetArray
I need time to investigate it, but for now, I'll pause it for a few days just to use this package/branch to catch up with my daily work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed all your code changes so far
Thanks for working on this
test/operations/tst_either.jl
Outdated
@@ -117,68 +117,68 @@ end | |||
@test Augmentor.supports_view(op) === false | |||
@test Augmentor.supports_stepview(op) === false | |||
@test Augmentor.supports_permute(op) === false | |||
@test @inferred(Augmentor.applyeager(op, img)) == rotl90(rect) | |||
@test typeof(Augmentor.applyeager(op, img)) <: OffsetArray | |||
@test @inferred(Augmentor.applyeager(op, img, Augmentor.randparam(op, img))) == rotl90(rect) # TODO: update 1.2: type instable if remove Augmentor.randparam |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it randparam
then?
@test_reference "reference/distort_static.txt" dv | ||
|
||
camerao = OffsetArray(camera, (-5,-10)) | ||
dv2 = @inferred Augmentor.DistortedView(camerao, A) | ||
@test size(dv2) == size(camera) | ||
@test eltype(dv2) == eltype(camera) | ||
@test summary(dv2) == "512×512 Augmentor.DistortedView(::OffsetArray{Gray{N0f8},2}, ::Array{Float64,3} as 3×3 vector field) with element type ColorTypes.Gray{FixedPointNumbers.Normed{UInt8,8}}" | ||
@test summary(dv2) == "512×512 Augmentor.DistortedView(::Array{Gray{N0f8},2}, ::Array{Float64,3} as 3×3 vector field) with eltype Gray{Normed{UInt8,8}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's related to my previous added specification to DistortedView
It's a WIP commit, I'll recheck that later when I fix julia 1.3 deprecations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rechecked in 733e32b and it should be a safe change here (as far as I understand the codebase)
To successfully compare two DistortedView
s A
and B
, their axes should be the same, i.e., axes(A)==axes(B)
, so I add the plain_axes
in the construction method to make sure this. This is still lazy-mode since plain_axes
doesn't copy data. The test in tst_distortion.jl
checks that as well.
I tried to use git blame to find out how in the previous codes two arrays of different axes can compare successfully but I failed, so I find another path here.
Although I think this change meets the goal of DistortedView
, it does change the behavior, hence you might need to review this commit carefully. 😂
rand is thread-safe in julia 1.3
Good news is that except a random failure due to accuracy in |
amazing news! |
const rand_mutex = Ref{Threads.Mutex}() | ||
|
||
# constant overhead of about 80 ns compared to unsafe rand | ||
function safe_rand(args...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little worried here that I might misunderstand what "threadsafe" means here. Is that mean the following two scripts should output the same results?
Random.seed!(0)
Threads.@threads for i in 1:5
println(rand())
end
Random.seed!(0)
for i in 1:5
println(rand())
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no. This has no influence on the ordering that threads invoke save_rand
. It really just is about the function being threadsafe so that consecutive return values (regardless of calling thread) can be considered random
src/compat.jl
Outdated
if Pkg.installed()["ImageTransformations"] <= v"0.8.3" | ||
Interpolations.tweight(A::AbstractArray{C}) where C<:FixedPoint = C | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems not a good idea. 👎 and it breaks the nightly test
end | ||
@inline function applyview(op::Either, img::AbstractArray) | ||
applyview(op, img, randparam(op, img)) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general definition is in operation.jl
for FUN in (:applyeager, :applylazy, :applypermute,
:applyaffine, :applyaffineview,
:applyaffine_common, :applyaffineview_common,
:applyview, :applystepview)
@eval begin
function ($FUN)(op::Operation, imgs::Tuple)
param = randparam(op, imgs)
map(img -> ($FUN)(op, img, param), imgs)
end
@inline function ($FUN)(op::Operation, img::AbstractArray)
($FUN)(op, img, randparam(op, img))
end
end
end
But the inferred type for Either
will be Any
(without using _offsetarray
) or OffsetArray
. Add a specialization here tells the compiler more type information.
This reverts commit a698382.
* add Project.toml * update test for cache and minor fix * update test for rotation and minor fix * update flipdm to reverse JuliaLang/julia#26369 * update test for crop and minor fix * update test for resize * update test for scale and minor fix * update test for zoom and minor fix * WIP: update test for distortion and minor fix * update test for either and minor fix * fix pipeline test * update summary reference for distortedview * WIP: fix tests for augment and operations * drop julia 0.7 and update CI * use FileIO v1.1.0 JuliaIO/FileIO.jl#245 * add 1.x tests to CI * revert back unnecessary changes * test windows in travis * fix randomly failed test cases for inacuraccy reasons * update to julia 1.1 * maybe_copy doesn't explain its usage * replace Slice by OffsetArrays.IdentityUnitRange JuliaArrays/OffsetArrays.jl#62 * update to julia 1.2 -- part I * WIP: update to julia 1.2 -- part II detect some type instable test cases, only the outmost wrapper is instable here * unify how types are displayed Only meta operations such as Either, Pipeline doesn't have Agumentor prefix * add more test versions * move safe_rand to compat.jl rand is thread-safe in julia 1.3 * don't allow failures for julia 1.3 * fix commit "WIP: update 1.0" * use explicit and intuitive CartesianIndex(1, 1) * add method specialization for tweight * allow FileIO 1.2 * fix type instability for Either * update reference for FixedPointNumbers v0.7 * try: relax equality check for scale * restore test cases in tst_scale.jl * Revert "add method specialization for tweight" This reverts commit a698382. * Augmentor v0.6.0-pre
This PR continues #27 and the road I choose is to:
tst_scale.jl
OffsetArray 1.0
There're some type-instability cases detected, which I've added a TODO comment for that, and probably fix them in a separate future PR.
To easily review the differences, the current base is set to
update0.7
, will change it tomaster
before merging.