Skip to content

Commit

Permalink
resolve showcoloranttype issue. closes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
Evizero committed Nov 13, 2017
1 parent ac562c0 commit f451b98
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 16 deletions.
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v0.3.1

Small fixes:

- Update some internals to comply with upstream changes to
ImageCore (v0.5.0) and ColorTypes (v0.6.6).

# v0.3.0

New functionality:
Expand Down
4 changes: 2 additions & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
julia 0.6
MappedArrays 0.0.3
ImageCore 0.1.2
ImageCore 0.5.0
ImageTransformations 0.3.0
ImageFiltering 0.1.4
CoordinateTransformations 0.4.0
Expand All @@ -9,7 +9,7 @@ Rotations
StaticArrays
OffsetArrays
IdentityRanges
ColorTypes 0.4
ColorTypes 0.6.6
MLDataPattern 0.1.2
ComputationalResources 0.0.2
ShowItLikeYouBuildIt
Expand Down
2 changes: 1 addition & 1 deletion src/operations/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ end
function showconstruction(io::IO, op::CacheImageInto)
print(io, "CacheImage(") # shows exported API
print(io, "Array{")
ColorTypes.showcoloranttype(io, eltype(op.buffer))
_showcolor(io, eltype(op.buffer))
print(io, "}(")
print(io, join(map(i->string(length(i)), indices(op.buffer)), ", "))
print(io, "))")
Expand Down
4 changes: 2 additions & 2 deletions src/operations/channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ end

function showconstruction(io::IO, op::CombineChannels)
print(io, typeof(op).name.name, '(')
ColorTypes.showcoloranttype(io, op.colortype)
_showcolor(io, op.colortype)
print(io, ')')
end

function Base.show(io::IO, op::CombineChannels)
if get(io, :compact, false)
print(io, "Combine color channels into colorant ")
ColorTypes.showcoloranttype(io, op.colortype)
_showcolor(io, op.colortype)
else
print(io, "Augmentor.")
showconstruction(io, op)
Expand Down
4 changes: 2 additions & 2 deletions src/operations/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ end

function showconstruction(io::IO, op::ConvertEltype)
print(io, typeof(op).name.name, '(')
ColorTypes.showcoloranttype(io, op.eltype)
_showcolor(io, op.eltype)
print(io, ')')
end

function Base.show(io::IO, op::ConvertEltype)
if get(io, :compact, false)
print(io, "Convert eltype to ")
ColorTypes.showcoloranttype(io, op.eltype)
_showcolor(io, op.eltype)
else
print(io, "Augmentor.")
showconstruction(io, op)
Expand Down
3 changes: 3 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ function unionrange(i1::AbstractUnitRange, i2::AbstractUnitRange)
map(min, first(i1), first(i2)):map(max, last(i1), last(i2))
end

@inline _showcolor(io::IO, T::Type{<:Number}) = print(io, T)
@inline _showcolor(io::IO, T) = ColorTypes.colorant_string_with_eltype(io, T)

# --------------------------------------------------------------------

function _2dborder!(A::AbstractArray{T,3}, val::T) where T
Expand Down
2 changes: 1 addition & 1 deletion test/operations/tst_cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ end
op = @inferred CacheImage(buf)
@test Augmentor.CacheImageInto(buf) === op
@test str_show(op) == "Augmentor.CacheImageInto(::Array{Gray{N0f8},2})"
@test_broken str_showconst(op) == "CacheImage(Array{Gray{N0f8}}(2, 3))"
@test str_showconst(op) == "CacheImage(Array{Gray{N0f8}}(2, 3))"
op2 = @inferred CacheImage(Array{Gray{N0f8}}(2, 3))
@test typeof(op) == typeof(op2)
@test typeof(op.buffer) == typeof(op2.buffer)
Expand Down
8 changes: 4 additions & 4 deletions test/operations/tst_channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ end
@test_throws MethodError CombineChannels(Float64)
@test typeof(@inferred(CombineChannels(RGB))) <: CombineChannels <: Augmentor.Operation
@test typeof(@inferred(CombineChannels(RGB{N0f8}))) <: CombineChannels <: Augmentor.Operation
@test_broken str_show(CombineChannels(RGB)) == "Augmentor.CombineChannels(RGB{Any})"
@test_broken str_show(CombineChannels(Gray{N0f8})) == "Augmentor.CombineChannels(Gray{N0f8})"
@test_broken str_showconst(CombineChannels(RGB{N0f8})) == "CombineChannels(RGB{N0f8})"
@test_broken str_showcompact(CombineChannels(Gray)) == "Combine color channels into colorant Gray{Any}"
@test str_show(CombineChannels(RGB)) == "Augmentor.CombineChannels(RGB{Any})"
@test str_show(CombineChannels(Gray{N0f8})) == "Augmentor.CombineChannels(Gray{N0f8})"
@test str_showconst(CombineChannels(RGB{N0f8})) == "CombineChannels(RGB{N0f8})"
@test str_showcompact(CombineChannels(Gray)) == "Combine color channels into colorant Gray{Any}"
end
@testset "eager" begin
@test Augmentor.supports_eager(CombineChannels) === false
Expand Down
8 changes: 4 additions & 4 deletions test/operations/tst_convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
@test typeof(@inferred(ConvertEltype(RGB))) <: ConvertEltype <: Augmentor.Operation
@test typeof(@inferred(ConvertEltype(RGB{N0f8}))) <: ConvertEltype <: Augmentor.Operation
@test str_show(ConvertEltype(Float64)) == "Augmentor.ConvertEltype(Float64)"
@test_broken str_show(ConvertEltype(RGB)) == "Augmentor.ConvertEltype(RGB{Any})"
@test_broken str_show(ConvertEltype(Gray{N0f8})) == "Augmentor.ConvertEltype(Gray{N0f8})"
@test str_show(ConvertEltype(RGB)) == "Augmentor.ConvertEltype(RGB{Any})"
@test str_show(ConvertEltype(Gray{N0f8})) == "Augmentor.ConvertEltype(Gray{N0f8})"
@test str_showconst(ConvertEltype(Float64)) == "ConvertEltype(Float64)"
@test_broken str_showconst(ConvertEltype(RGB{N0f8})) == "ConvertEltype(RGB{N0f8})"
@test str_showconst(ConvertEltype(RGB{N0f8})) == "ConvertEltype(RGB{N0f8})"
@test str_showcompact(ConvertEltype(Float64)) == "Convert eltype to Float64"
@test_broken str_showcompact(ConvertEltype(Gray)) == "Convert eltype to Gray{Any}"
@test str_showcompact(ConvertEltype(Gray)) == "Convert eltype to Gray{Any}"
end
@testset "eager" begin
@test Augmentor.supports_eager(ConvertEltype) === true
Expand Down

0 comments on commit f451b98

Please sign in to comment.