-
Notifications
You must be signed in to change notification settings - Fork 40
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
add center/centered helpers #242
Conversation
""" | ||
function center(A::AbstractArray, r::RoundingMode=RoundDown) | ||
map(axes(A)) do inds | ||
round(Int, (length(inds)-1)/2, r) + first(inds) |
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 default RoundDown
and length(inds)-1
is chosen to match the previous ImageFiltering.centered
behavior:
julia> A = reshape(collect(1:6), 2, 3)
2×3 Matrix{Int64}:
1 3 5
2 4 6
julia> OffsetArrays.centered(A) == ImageFiltering.centered(A)
true
Codecov Report
@@ Coverage Diff @@
## master #242 +/- ##
==========================================
+ Coverage 95.33% 95.37% +0.04%
==========================================
Files 5 5
Lines 407 411 +4
==========================================
+ Hits 388 392 +4
Misses 19 19
Continue to review full report at Codecov.
|
Sometimes, it will be convenient to shift the center coordinate of the given array to `(0, 0, ...)`, | ||
`OffsetArrays.centered` is a helper for this very purpose: | ||
|
||
```@repl index |
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.
should these be doctests instead?
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 doctests are already in the src/
and test/
so I think it's okay to just follow the previous doc format here.
LGTM |
closes #169