Skip to content

Commit

Permalink
Use ReshapedArray for show() (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
kescobo authored and timholy committed Oct 25, 2018
1 parent bc72215 commit 835d445
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ function Base.show(io::IO, ::MIME"image/svg+xml", c::Color)
""")
end

function Base.show(io::IO, ::MIME"image/svg+xml",
function Base.show(io::IO, ::MIME"image/svg+xml",
cs::AbstractVector{T}) where T <: Color
show(io, MIME"image/svg+xml"(), reshape(cs, (1, length(cs))))
show(io, MIME"image/svg+xml"(), Base.ReshapedArray(cs, (1, length(cs)), ()))
end

function Base.show(io::IO, ::MIME"image/svg+xml",
Expand Down
6 changes: 6 additions & 0 deletions test/colormaps.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
@testset "Colormaps" begin
@test length(colormap("RdBu", 100)) == 100

# test ability to add to previously shown array of colors - issue #328
a = [colorant"white", colorant"red"]
show(stdout, MIME"image/svg+xml"(), a)
push!(a, colorant"blue")
@test length(a) == 3
end

0 comments on commit 835d445

Please sign in to comment.