We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e9b086d + e2584b5 commit 2449575Copy full SHA for 2449575
src/ColorVectorSpace.jl
@@ -9,7 +9,7 @@ import Base: ==, +, -, *, /, .+, .-, .*, ./, ^, .^, <, ~
9
import Base: abs, abs2, clamp, convert, copy, div, eps, isfinite, isinf,
10
isnan, isless, length, mapreduce, norm, one, promote_array_type,
11
promote_op, promote_rule, zero, trunc, floor, round, ceil, bswap,
12
- mod, rem, atan2, hypot, max, min, varm, real
+ mod, rem, atan2, hypot, max, min, varm, real, typemin, typemax
13
14
export nan
15
@@ -460,4 +460,6 @@ histrange{T}(v::AbstractArray{Gray{T}}, n::Integer) = histrange(convert(Array{Fl
460
promote_array_type{T<:Real,C<:MathTypes}(F, ::Type{T}, ::Type{C}) = base_colorant_type(C){Base.promote_array_type(F, T, eltype(C))}
461
promote_rule{T<:Real,C<:AbstractGray}(::Type{T}, ::Type{C}) = promote_type(T, eltype(C))
462
463
+typemin{T<:ColorTypes.AbstractGray}(::Union{T,Type{T}}) = T(typemin(eltype(T)))
464
+typemax{T<:ColorTypes.AbstractGray}(::Union{T,Type{T}}) = T(typemax(eltype(T)))
465
end
test/runtests.jl
@@ -340,7 +340,18 @@ end
340
@test isapprox(dotc(xc, yc) , dotc(convert(Gray, xc), convert(Gray, yc)), atol=1e-6)
341
@test dotc(RGB(1,0,0), RGB(0,1,1)) == 0
342
343
-end
344
+ @testset "typemin/max" begin
345
+ for T in (Normed{UInt8,8}, Normed{UInt8,6}, Normed{UInt16,16}, Normed{UInt16,14}, Float32, Float64)
346
+ @test typemin(Gray{T}) === Gray{T}(typemin(T))
347
+ @test typemax(Gray{T}) === Gray{T}(typemax(T))
348
+ @test typemin(Gray{T}(0.5)) === Gray{T}(typemin(T))
349
+ @test typemax(Gray{T}(0.5)) === Gray{T}(typemax(T))
350
+ A = maximum(Gray{T}.([1 0 0; 0 1 0]), 1) # see PR#44 discussion
351
+ @test isa(A, Matrix{Gray{T}})
352
+ @test size(A) == (1,3)
353
+ end
354
355
+end
356
357
0 commit comments