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

Fix show for images with offset axes #6

Merged
merged 1 commit into from
Nov 14, 2018
Merged

Fix show for images with offset axes #6

merged 1 commit into from
Nov 14, 2018

Conversation

timholy
Copy link
Member

@timholy timholy commented Nov 13, 2018

Fixes JuliaImages/Images.jl#717. CC @zygmuntszpak (who is not watching but commented on that issue).

@timholy
Copy link
Member Author

timholy commented Nov 13, 2018

I should have mentioned, I saw three solutions:

  • generalize repeat in Base to work with arbitrary indices
  • implement a specialized method for repeat in OffsetArrays
  • this PR

The reason I chose this approach is that it's not entirely clear what the output array's axes should be when calling repeat. Consequently it may be better to leave it undefined (and perhaps we should throw an error for any non-1 indices).

@codecov
Copy link

codecov bot commented Nov 13, 2018

Codecov Report

Merging #6 into master will decrease coverage by 35.53%.
The diff coverage is 66.66%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master       #6       +/-   ##
===========================================
- Coverage   97.87%   62.33%   -35.54%     
===========================================
  Files           2        2               
  Lines          47       77       +30     
===========================================
+ Hits           46       48        +2     
- Misses          1       29       +28
Impacted Files Coverage Δ
src/ImageShow.jl 33.33% <ø> (-66.67%) ⬇️
src/showmime.jl 63.51% <66.66%> (-34.32%) ⬇️

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 dd8ccac...3df9e66. Read the comment docs.

src/showmime.jl Outdated
@@ -42,6 +45,9 @@ function Base.show(io::IO, mime::MIME"image/png", img::AbstractMatrix{C};
end
end

Base.show(io::IO, mime::MIME"image/png", img::OffsetArray{C}; kwargs...) where C =
Copy link
Member

Choose a reason for hiding this comment

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

should C be restricted to Colorant? I guess it doesn't matter for a non Colorant when the MethodError(show, ...) is thrown one level deeper (it should just continue to walk the display stack). But I am guessing that it messes with the result of showable which falls back to hasmethod. thoughts?

@timholy timholy merged commit f8db749 into master Nov 14, 2018
@timholy timholy deleted the teh/repeat branch November 14, 2018 08:47
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