@@ -2,14 +2,17 @@ __precompile__(true)
22
33module ColorVectorSpace
44
5- using Colors, FixedPointNumbers, SpecialFunctions, Compat
6- import StatsBase: histrange
5+ using Colors, FixedPointNumbers, SpecialFunctions
76
87import Base: == , + , - , * , / , ^ , < , ~
98import Base: abs, abs2, clamp, convert, copy, div, eps, isfinite, isinf,
10- isnan, isless, length, mapreduce, norm, oneunit, promote_array_type ,
9+ isnan, isless, length, mapreduce, oneunit,
1110 promote_op, promote_rule, zero, trunc, floor, round, ceil, bswap,
12- mod, rem, atan2, hypot, max, min, varm, real, typemin, typemax
11+ mod, rem, atan2, hypot, max, min, real, typemin, typemax
12+ import LinearAlgebra: norm
13+ import StatsBase: histrange, varm
14+ import SpecialFunctions: gamma, lgamma, lfact
15+ import Statistics: middle
1316
1417export nan
1518
@@ -23,9 +26,9 @@ import Base: conj, sin, cos, tan, sinh, cosh, tanh,
2326 asind, atand, rad2deg, deg2rad,
2427 log, log2, log10, log1p, exponent, exp,
2528 exp2, expm1, cbrt, sqrt,
26- significand, lgamma,
27- gamma, lfact, frexp, modf,
28- float, middle
29+ significand,
30+ frexp, modf,
31+ float
2932
3033export dotc
3134
6063
6164for f in (:trunc , :floor , :round , :ceil , :eps , :bswap )
6265 @eval $ f (g:: Gray{T} ) where {T} = Gray {T} ($ f (gray (g)))
63- @eval Compat. @dep_vectorize_1arg Gray $ f
6466end
6567eps (:: Type{Gray{T}} ) where {T} = Gray (eps (T))
66- Compat. @dep_vectorize_1arg AbstractGray isfinite
67- Compat. @dep_vectorize_1arg AbstractGray isinf
68- Compat. @dep_vectorize_1arg AbstractGray isnan
69- Compat. @dep_vectorize_1arg AbstractGray abs
70- Compat. @dep_vectorize_1arg AbstractGray abs2
68+
7169for f in (:trunc , :floor , :round , :ceil )
7270 @eval $ f (:: Type{T} , g:: Gray ) where {T<: Integer } = Gray {T} ($ f (T, gray (g)))
7371end
@@ -274,7 +272,7 @@ function Base.isapprox(x::AbstractArray{Cx},
274272 y:: AbstractArray{Cy} ;
275273 rtol:: Real = Base. rtoldefault (eltype (Cx),eltype (Cy),0 ),
276274 atol:: Real = 0 ,
277- norm:: Function = vecnorm ) where {Cx<: MathTypes ,Cy<: MathTypes }
275+ norm:: Function = norm ) where {Cx<: MathTypes ,Cy<: MathTypes }
278276 d = norm (x - y)
279277 if isfinite (d)
280278 return d <= atol + rtol* max (norm (x), norm (y))
@@ -293,16 +291,8 @@ dotc(x::AbstractGray, y::AbstractGray) = dotc(promote(x, y)...)
293291float (:: Type{T} ) where {T<: Gray } = typeof (float (zero (T)))
294292
295293# Mixed types
296- if VERSION < v " 0.7.0-DEV.2138"
297- (+ )(a:: MathTypes , b:: MathTypes ) = (+ )(Base. promote_noncircular (a, b)... )
298- (- )(a:: MathTypes , b:: MathTypes ) = (- )(Base. promote_noncircular (a, b)... )
299- else
300- (+ )(a:: MathTypes , b:: MathTypes ) = (+ )(promote (a, b)... )
301- (- )(a:: MathTypes , b:: MathTypes ) = (- )(promote (a, b)... )
302- end
303-
304- Compat. @dep_vectorize_2arg Gray max
305- Compat. @dep_vectorize_2arg Gray min
294+ (+ )(a:: MathTypes , b:: MathTypes ) = (+ )(promote (a, b)... )
295+ (- )(a:: MathTypes , b:: MathTypes ) = (- )(promote (a, b)... )
306296
307297# Arrays
308298+ (A:: AbstractArray{C} ) where {C<: MathTypes } = A
@@ -345,7 +335,6 @@ real(::Type{C}) where {C<:AbstractGray} = real(eltype(C))
345335histrange (v:: AbstractArray{Gray{T}} , n:: Integer ) where {T} = histrange (convert (Array{Float32}, map (gray, v)), n, :right )
346336
347337# To help type inference
348- promote_array_type (F, :: Type{T} , :: Type{C} ) where {T<: Real ,C<: MathTypes } = base_colorant_type (C){Base. promote_array_type (F, T, eltype (C))}
349338promote_rule (:: Type{T} , :: Type{C} ) where {T<: Real ,C<: AbstractGray } = promote_type (T, eltype (C))
350339
351340typemin (:: Type{T} ) where {T<: ColorTypes.AbstractGray } = T (typemin (eltype (T)))
@@ -354,18 +343,4 @@ typemax(::Type{T}) where {T<:ColorTypes.AbstractGray} = T(typemax(eltype(T)))
354343typemin (:: T ) where {T<: ColorTypes.AbstractGray } = T (typemin (eltype (T)))
355344typemax (:: T ) where {T<: ColorTypes.AbstractGray } = T (typemax (eltype (T)))
356345
357- # deprecations
358- function Base. one (:: Type{C} ) where {C<: Union{TransparentGray,AbstractRGB,TransparentRGB} }
359- Base. depwarn (" one($C ) will soon switch to returning 1; you might need to switch to `oneunit`" , :one )
360- C (_onetuple (C)... )
361- end
362- _onetuple (:: Type{C} ) where {C<: Colorant{T,N} } where {T,N} = ntuple (d-> 1 , Val (N))
363-
364- for f in (:min , :max )
365- @eval begin
366- @deprecate ($ f {T<:Gray} (x:: Number , y:: AbstractArray{T} ), $ f .(x, y))
367- @deprecate ($ f {T<:Gray} (x:: AbstractArray{T} , y:: Number ), $ f .(x, y))
368- end
369- end
370-
371346end
0 commit comments