-
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
Fix array constructor #416
Conversation
OK - something is weird here... In a different project:
But in this project
I don't understand why I'm getting a |
I'm unable to reproduce the issue, using the master branch of julia> img1 = rand(RGB, 3,2); img2 = rand(RGB, 3, 3);
julia> m = mortar([[img1] [img2]]);
julia> io = IOBuffer();
julia> show(io, "image/png", m) # this is the original error
ERROR: MethodError: no method matching show(::IOBuffer, ::MIME{Symbol("image/png")}, ::BlockMatrix{RGB{Float64}, Matrix{Matrix{RGB{Float64}}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}, BlockedOneTo{Int64, Vector{Int64}}}})
Closest candidates are:
show(::IO, ::MIME{Symbol("text/plain")}, ::AbstractArray)
@ Base arrayshow.jl:363
show(::IO, ::MIME{Symbol("text/plain")}, ::Any)
@ Base multimedia.jl:47
show(::IO, ::MIME{Symbol("image/svg+xml")}, ::AbstractMatrix{T}; max_swatches) where T<:Color
@ Colors ~/.julia/packages/Colors/E2qak/src/display.jl:99
...
Stacktrace:
[1] show(io::IOBuffer, m::String, x::BlockMatrix{RGB{Float64}, Matrix{Matrix{RGB{Float64}}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}, BlockedOneTo{Int64, Vector{Int64}}}})
@ Base.Multimedia ./multimedia.jl:123
[2] top-level scope
@ REPL[5]:1
julia> function Base.Array(block_array::BlockArray{T, N, R}) where {T,N,R}
arr = Array{T}(undef, size(block_array))
for block_index in Iterators.product(blockaxes(block_array)...)
indices = getindex.(axes(block_array), block_index)
arr[indices...] = @view block_array[block_index...]
end
return arr
end
julia> show(io, "image/png", m) # no error
ERROR: MethodError: no method matching show(::IOBuffer, ::MIME{Symbol("image/png")}, ::BlockMatrix{RGB{Float64}, Matrix{Matrix{RGB{Float64}}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}, BlockedOneTo{Int64, Vector{Int64}}}})
Closest candidates are:
show(::IO, ::MIME{Symbol("text/plain")}, ::AbstractArray)
@ Base arrayshow.jl:363
show(::IO, ::MIME{Symbol("text/plain")}, ::Any)
@ Base multimedia.jl:47
show(::IO, ::MIME{Symbol("image/svg+xml")}, ::AbstractMatrix{T}; max_swatches) where T<:Color
@ Colors ~/.julia/packages/Colors/E2qak/src/display.jl:99
...
Stacktrace:
[1] show(io::IOBuffer, m::String, x::BlockMatrix{RGB{Float64}, Matrix{Matrix{RGB{Float64}}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}, BlockedOneTo{Int64, Vector{Int64}}}})
@ Base.Multimedia ./multimedia.jl:123
[2] top-level scope
@ REPL[7]:1 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #416 +/- ##
=======================================
Coverage 96.66% 96.66%
=======================================
Files 18 18
Lines 1649 1649
=======================================
Hits 1594 1594
Misses 55 55 ☔ View full report in Codecov by Sentry. |
🤔 You're right. Seems like the show method is added by This seems to work locally - I had it this way a couple of commits ago, but thought it didn't work for some reason 🤷 |
Could you bump the patch version so that a release may be tagged? |
@@ -549,7 +549,7 @@ function Base.Array(zerodim::BlockArray{T, 0}) where {T} | |||
end | |||
|
|||
function Base.Array(block_array::BlockArray{T, N, R}) where {T,N,R} | |||
arr = Array{eltype(T)}(undef, size(block_array)) | |||
arr = Array{T}(undef, size(block_array)) |
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 wonder why this is marked as untested?
Closes #415
Is there a better way to test the
show
output? What I really want is the inverse of@test_throws
, but this way at least it checks that this doesn't error