Skip to content

Commit 91e3c10

Browse files
authored
Merge pull request #84 from JuliaGraphics/teh/fix0.7
Fix on 0.7
2 parents 32835c2 + ac70431 commit 91e3c10

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

REQUIRE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ ColorTypes 0.6.3
44
FixedPointNumbers 0.3.0
55
StatsBase 0.8.2
66
Compat 0.18.0
7+
SpecialFunctions

src/ColorVectorSpace.jl

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ __precompile__(true)
22

33
module ColorVectorSpace
44

5-
using Colors, FixedPointNumbers, Compat
5+
using Colors, FixedPointNumbers, SpecialFunctions, Compat
66
import StatsBase: histrange
77

88
import Base: ==, +, -, *, /, ^, <, ~
@@ -22,13 +22,10 @@ import Base: conj, sin, cos, tan, sinh, cosh, tanh,
2222
sind, tand, acosd, acotd, acscd, asecd,
2323
asind, atand, rad2deg, deg2rad,
2424
log, log2, log10, log1p, exponent, exp,
25-
exp2, expm1, cbrt, sqrt, erf,
26-
erfc, erfcx, erfi, dawson,
25+
exp2, expm1, cbrt, sqrt,
2726
significand, lgamma,
28-
gamma, lfact, frexp, modf, airy, airyai,
29-
airyprime, airyaiprime, airybi, airybiprime,
30-
besselj0, besselj1, bessely0, bessely1,
31-
eta, zeta, digamma, float, middle
27+
gamma, lfact, frexp, modf,
28+
float, middle
3229

3330
export dotc
3431

@@ -53,7 +50,11 @@ _nan(::Type{T}, ::Type{C}) where {T<:AbstractFloat,C<:TransparentRGB} = (x = con
5350
## Generic algorithms
5451
mapreduce(f, op::Union{typeof(&), typeof(|)}, a::MathTypes) = f(a) # ambiguity
5552
mapreduce(f, op, a::MathTypes) = f(a)
56-
Base.r_promote(::typeof(+), c::MathTypes) = mapc(x->Base.r_promote(+, x), c)
53+
if isdefined(Base, :r_promote)
54+
Base.r_promote(::typeof(+), c::MathTypes) = mapc(x->Base.r_promote(+, x), c)
55+
else
56+
Base.promote_sys_size_add(c::MathTypes) = mapc(Base.promote_sys_size_add, c)
57+
end
5758

5859
for f in (:trunc, :floor, :round, :ceil, :eps, :bswap)
5960
@eval $f(g::Gray{T}) where {T} = Gray{T}($f(gray(g)))
@@ -198,13 +199,15 @@ const unaryOps = (:~, :conj, :abs,
198199
:sind, :tand, :acosd, :acotd, :acscd, :asecd,
199200
:asind, :atand, :rad2deg, :deg2rad,
200201
:log, :log2, :log10, :log1p, :exponent, :exp,
201-
:exp2, :expm1, :cbrt, :sqrt, :erf,
202-
:erfc, :erfcx, :erfi, :dawson,
202+
:exp2, :expm1, :cbrt, :sqrt,
203203
:significand, :lgamma,
204-
:gamma, :lfact, :frexp, :modf, :airy, :airyai,
205-
:airyprime, :airyaiprime, :airybi, :airybiprime,
206-
:besselj0, :besselj1, :bessely0, :bessely1,
207-
:eta, :zeta, :digamma)
204+
:gamma, :lfact, :frexp, :modf,
205+
:(SpecialFunctions.erf), :(SpecialFunctions.erfc),
206+
:(SpecialFunctions.erfcx), :(SpecialFunctions.erfi), :(SpecialFunctions.dawson),
207+
:(SpecialFunctions.airy), :(SpecialFunctions.airyai),
208+
:(SpecialFunctions.airyprime), :(SpecialFunctions.airyaiprime), :(SpecialFunctions.airybi), :(SpecialFunctions.airybiprime),
209+
:(SpecialFunctions.besselj0), :(SpecialFunctions.besselj1), :(SpecialFunctions.bessely0), :(SpecialFunctions.bessely1),
210+
:(SpecialFunctions.eta), :(SpecialFunctions.zeta), :(SpecialFunctions.digamma))
208211
for op in unaryOps
209212
@eval ($op)(c::AbstractGray) = $op(gray(c))
210213
end
@@ -288,8 +291,13 @@ dotc(x::AbstractGray, y::AbstractGray) = dotc(promote(x, y)...)
288291
float(::Type{T}) where {T<:Gray} = typeof(float(zero(T)))
289292

290293
# Mixed types
291-
(+)(a::MathTypes, b::MathTypes) = (+)(Base.promote_noncircular(a, b)...)
292-
(-)(a::MathTypes, b::MathTypes) = (-)(Base.promote_noncircular(a, b)...)
294+
if VERSION < v"0.7.0-DEV.2138"
295+
(+)(a::MathTypes, b::MathTypes) = (+)(Base.promote_noncircular(a, b)...)
296+
(-)(a::MathTypes, b::MathTypes) = (-)(Base.promote_noncircular(a, b)...)
297+
else
298+
(+)(a::MathTypes, b::MathTypes) = (+)(promote(a, b)...)
299+
(-)(a::MathTypes, b::MathTypes) = (-)(promote(a, b)...)
300+
end
293301

294302
Compat.@dep_vectorize_2arg Gray max
295303
Compat.@dep_vectorize_2arg Gray min

test/runtests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ end
5757
@test 2.0f0*cu == Gray(2.0f0*cu.val)
5858
f = N0f8(0.5)
5959
@test (f*cu).val f*cu.val
60-
@test 2.*cf == ccmp
60+
@test 2 .* cf == ccmp
6161
@test cf.*2 == ccmp
6262
@test cf/2.0f0 == Gray{Float32}(0.05)
6363
@test cu/2 == Gray(cu.val/2)
@@ -94,7 +94,7 @@ end
9494
@test typeof(acu.+cf) == Vector{Gray{Float32}}
9595
@test typeof(acu.-cf) == Vector{Gray{Float32}}
9696
@test typeof(2*acf) == Vector{Gray{Float32}}
97-
@test typeof(2.*acf) == Vector{Gray{Float32}}
97+
@test typeof(2 .* acf) == Vector{Gray{Float32}}
9898
@test typeof(0x02*acu) == Vector{Gray{Float32}}
9999
@test typeof(acu/2) == Vector{Gray{typeof(N0f8(0.5)/2)}}
100100
@test typeof(acf.^2) == Vector{Gray{Float32}}
@@ -225,7 +225,7 @@ end
225225
@test_colortype_approx_eq 2.0f0*cu RGB(2.0f0*cu.r, 2.0f0*cu.g, 2.0f0*cu.b)
226226
f = N0f8(0.5)
227227
@test (f*cu).r f*cu.r
228-
@test 2.*cf == ccmp
228+
@test 2 .* cf == ccmp
229229
@test cf.*2 == ccmp
230230
@test cf/2.0f0 == RGB{Float32}(0.05,0.1,0.15)
231231
@test cu/2 RGB(cu.r/2,cu.g/2,cu.b/2)
@@ -300,7 +300,7 @@ end
300300
@test_colortype_approx_eq 2.0f0*cu RGBA(2.0f0*cu.r, 2.0f0*cu.g, 2.0f0*cu.b, 2.0f0*cu.alpha)
301301
f = N0f8(0.5)
302302
@test (f*cu).r f*cu.r
303-
@test 2.*cf == ccmp
303+
@test 2 .* cf == ccmp
304304
@test cf.*2 == ccmp
305305
@test cf/2.0f0 == RGBA{Float32}(0.05,0.1,0.15,0.2)
306306
@test cu/2 == RGBA(cu.r/2,cu.g/2,cu.b/2,cu.alpha/2)

0 commit comments

Comments
 (0)