Skip to content

Commit

Permalink
Fix one(c) depwarn (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Dec 8, 2019
1 parent 9bc4b19 commit 775cacd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ channel separately.
See also: [`clamp01!`](@ref), [`clamp01nan`](@ref).
"""
clamp01(x::Union{N0f8,N0f16}) = x
clamp01(x::Number) = clamp(x, zero(x), one(x))
clamp01(x::Number) = clamp(x, zero(x), oneunit(x))
clamp01(c::Colorant) = mapc(clamp01, c)

"""
Expand Down Expand Up @@ -209,7 +209,7 @@ The default colors are:
See also: [`scalesigned`](@ref).
"""
colorsigned(neg::C, center::C, pos::C) where {C<:Colorant} = function(x)
y = clamp(x, -one(x), one(x))
y = clamp(x, -oneunit(x), oneunit(x))
yabs = abs(y)
C(ifelse(y>0, weighted_color_mean(yabs, pos, center),
weighted_color_mean(yabs, neg, center)))
Expand Down
1 change: 1 addition & 0 deletions test/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ using Test
@test f( 0.5) mapc(N0f8, 0.5w+0.5m)
@test f(-0.25) mapc(N0f8, 0.25g+0.75w)
@test f( 0.75) mapc(N0f8, 0.75m+0.25w)
@test f(Gray(0.75)) mapc(N0f8, 0.75m+0.25w)
end
g, w, m = RGBA(0.,1.,0.,1.), RGBA(1.,1.,1.,0.), RGBA(1.,0.,1.,1.)
f = colorsigned(g, w, m)
Expand Down

0 comments on commit 775cacd

Please sign in to comment.