-
Notifications
You must be signed in to change notification settings - Fork 27
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
upgrade legacy methods with cleaner keyword alternative #116
Conversation
Codecov Report
@@ Coverage Diff @@
## master #116 +/- ##
==========================================
- Coverage 95.02% 94.09% -0.93%
==========================================
Files 7 8 +1
Lines 362 322 -40
==========================================
- Hits 344 303 -41
- Misses 18 19 +1
Continue to review full report at Codecov.
|
I took the liberty to rewrite the documentation in e0ac5cb and I think this PR is done. It's already quite big so I hope to continue the work in future PRs. @andrew-saydjari do you want to take a look at the docs change and comment? For example, if this makes things clearer, or makes it less readable. You can only read that commit difference by clicking it. |
The documentation changes seem fine to me and are, if anything, clearer. If I recall correctly, |
Nice catch! I totally forget about this difference until you mentioned it. Internally, # https://github.com/JuliaMath/Interpolations.jl/blob/e316c736a1369ccf0acd7ffea73af83172c07d34/src/b-splines/b-splines.jl#L159-L162
function interpolate(::Type{TWeights}, ::Type{TC}, A, it::IT) where {TWeights,TC,IT<:DimSpec{BSpline}}
Apad = prefilter(TWeights, TC, A, it)
BSplineInterpolation(TWeights, Apad, it, axes(A))
end I'm not interpolation experts so I don't know whether this "prefilter" step would do to our
Given that all The only difference is perhaps the performance: img = testimage("cameraman")
imrotate(img, 0.3; method=Linear()) == imrotate(img, 0.3; method=BSpline(Linear())) # true
@btime imrotate($img, 0.3; method=Linear()); # 3.479 ms (21 allocations: 403.88 KiB)
@btime imrotate($img, 0.3; method=BSpline(Linear())); # 3.491 ms (23 allocations: 660.02 KiB) I believe we could just do the same optimization to |
I think this PR is finally done, I'll do a rebase and then merge this. |
Julia's keyword argument is not very performant before Julia 1.0. IIUC, this is why this package used a lot of multiple dispatch tricks on positional arguments to work around the performance overhead. However, the unfortunate part of the non-orthogonal positional argument is that it easily blows the number of methods when more possibility comes and makes it prone to ambiguities(#115) and StackOverflow errors(#57), not to mention the maintenance burden (really hard to figure out the calling order).
This PR rewrites the internal interfaces to use keyword parameter
method=Linear()
andfillvalue = _default_fillvalue(T)
.API changes
All
degree
andfill
positional arguments are deprecated in favor of their keyword versionmethod
andfillvalue
. For simplicity, I didn't add type annotations here.imrotate(img, sizes, [degree], [fill])
->imrotate(img, sizes; [method], [fillvalue])
warp(img, tform, indices, [degree], [fill])
->warp(img, tform, indices; [method], [fillvalue])
WarpedView(img, tform, indices)
->WarpedView(img, tform, indices; [method], [fillvalue])
- [ ] (Behavior changed)InvWarpedView(img, tform, indices)
->InvWarpedView(img, tform, indices; [method], [fillvalue])
warpedview
in favor ofWarpedView
invwarpedview
in favor ofInvWarpedView
Old usages will still be tested in
test/deprecated.jl
so that it hopefully doesn't break people's code.Internal function changes:
box_extrapolation(img, [degree], [fill])
-> `box_extrapolation(img; method, fillvalue)_default_fill
->_default_fillvalue
IdentityRanges.IdentityRange
in favor ofBase.IdentityUnitRange
(deprecate this package in favor ofBase.IdentityUnitRange
JuliaArrays/IdentityRanges.jl#14)No deprecation warnings will be provided for them, and there will be no depwarn tests in
test/deprecated.jl
.code reorganization
This part is not yet done.compat.jl
deprecated.jl
Documentation
The docstrings will be rewritten in a more structured style outlined in JuliaImages/Images.jl#790. In the next PR, I'll set up the documentation CI.
Test changes
summary
test (future PR)summary
test is prone to internal changes and can be very different across multiple Julia versions. Thus they'll be replaced with other checks.After this PR, I'll set up the documentation and then tag
v0.9.0
. I still have some other schedules, but hopefully, I'll make it before May.cc: @andrew-saydjari @Evizero