Skip to content
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

restrict: only return OffsetArray when input is an OffsetArray #4

Merged
merged 1 commit into from
May 22, 2021

Conversation

johnnychen94
Copy link
Member

@johnnychen94 johnnychen94 commented May 22, 2021

Unless people's code depends on the array container type (e.g., out.parent), this isn't a breaking change.

img = rand(4, 4)
restrict(img)
# master: 1-based OffsetArray
# PR: Array

img = OffsetArray(rand(4, 4), -1, 0)
restrict(img) # behavior not changed

Also, add some more tests on the property.

@codecov
Copy link

codecov bot commented May 22, 2021

Codecov Report

Merging #4 (b5d2626) into master (eff14e9) will increase coverage by 0.34%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #4      +/-   ##
==========================================
+ Coverage   94.73%   95.08%   +0.34%     
==========================================
  Files           1        2       +1     
  Lines         114      122       +8     
==========================================
+ Hits          108      116       +8     
  Misses          6        6              
Impacted Files Coverage Δ
src/compat.jl 100.00% <100.00%> (ø)
src/restrict.jl 95.04% <100.00%> (+0.30%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eff14e9...b5d2626. Read the comment docs.

@johnnychen94 johnnychen94 merged commit d2197f6 into master May 22, 2021
@johnnychen94 johnnychen94 deleted the jc/offset branch May 22, 2021 21:33
@johnnychen94
Copy link
Member Author

johnnychen94 commented May 24, 2021

Actually, this 1-based OffsetArray output is introduced by the instability fixes: JuliaImages/ImageTransformations.jl#124.

It's not yet released, so I'm relieved that this unexpected change gets reverted.

restrict!(out, A, dim)
out
end
function restrict(A::OffsetArray{T,N}, dim::Integer) where {T,N}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better not to specialize on OffsetArray, because it's far from the only special array type in the universe. similar , supplied with appropriate axes for the result, should allocate the correct type for us. What's needed is a correct way to compute the axes of the returned value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants