Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/ColorVectorSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Base: ==, +, -, *, /, .+, .-, .*, ./, ^, .^, <, ~
import Base: abs, abs2, clamp, convert, copy, div, eps, isfinite, isinf,
isnan, isless, length, mapreduce, norm, one, promote_array_type,
promote_op, promote_rule, zero, trunc, floor, round, ceil, bswap,
mod, rem, atan2, hypot, max, min, varm, real
mod, rem, atan2, hypot, max, min, varm, real, typemin, typemax

export nan

Expand Down Expand Up @@ -460,4 +460,6 @@ histrange{T}(v::AbstractArray{Gray{T}}, n::Integer) = histrange(convert(Array{Fl
promote_array_type{T<:Real,C<:MathTypes}(F, ::Type{T}, ::Type{C}) = base_colorant_type(C){Base.promote_array_type(F, T, eltype(C))}
promote_rule{T<:Real,C<:AbstractGray}(::Type{T}, ::Type{C}) = promote_type(T, eltype(C))

typemin{T<:ColorTypes.AbstractGray}(::Union{T,Type{T}}) = T(typemin(eltype(T)))
typemax{T<:ColorTypes.AbstractGray}(::Union{T,Type{T}}) = T(typemax(eltype(T)))
end
13 changes: 12 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,18 @@ end
@test isapprox(dotc(xc, yc) , dotc(convert(Gray, xc), convert(Gray, yc)), atol=1e-6)
@test dotc(RGB(1,0,0), RGB(0,1,1)) == 0
end
end

@testset "typemin/max" begin
for T in (Normed{UInt8,8}, Normed{UInt8,6}, Normed{UInt16,16}, Normed{UInt16,14}, Float32, Float64)
@test typemin(Gray{T}) === Gray{T}(typemin(T))
@test typemax(Gray{T}) === Gray{T}(typemax(T))
@test typemin(Gray{T}(0.5)) === Gray{T}(typemin(T))
@test typemax(Gray{T}(0.5)) === Gray{T}(typemax(T))
A = maximum(Gray{T}.([1 0 0; 0 1 0]), 1) # see PR#44 discussion
@test isa(A, Matrix{Gray{T}})
@test size(A) == (1,3)
end
end
end

end