Skip to content

Commit 1104a12

Browse files
committed
Handle function movements across Base, stdlibs, and packages
1 parent 367c1c5 commit 1104a12

File tree

3 files changed

+15
-33
lines changed

3 files changed

+15
-33
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
julia 0.7-alpha
1+
julia 0.7.0-beta.85
22
Colors 0.7.1
33
ColorTypes 0.6.3
44
FixedPointNumbers 0.3.0

src/ColorVectorSpace.jl

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ __precompile__(true)
33
module ColorVectorSpace
44

55
using Colors, FixedPointNumbers, SpecialFunctions
6-
import StatsBase: histrange
76

87
import Base: ==, +, -, *, /, ^, <, ~
98
import 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

1417
export 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

3033
export dotc
3134

@@ -269,7 +272,7 @@ function Base.isapprox(x::AbstractArray{Cx},
269272
y::AbstractArray{Cy};
270273
rtol::Real=Base.rtoldefault(eltype(Cx),eltype(Cy),0),
271274
atol::Real=0,
272-
norm::Function=vecnorm) where {Cx<:MathTypes,Cy<:MathTypes}
275+
norm::Function=norm) where {Cx<:MathTypes,Cy<:MathTypes}
273276
d = norm(x - y)
274277
if isfinite(d)
275278
return d <= atol + rtol*max(norm(x), norm(y))
@@ -291,7 +294,6 @@ float(::Type{T}) where {T<:Gray} = typeof(float(zero(T)))
291294
(+)(a::MathTypes, b::MathTypes) = (+)(promote(a, b)...)
292295
(-)(a::MathTypes, b::MathTypes) = (-)(promote(a, b)...)
293296

294-
295297
# Arrays
296298
+(A::AbstractArray{C}) where {C<:MathTypes} = A
297299
+(A::Array{C}) where {C<:MathTypes} = A
@@ -333,7 +335,6 @@ real(::Type{C}) where {C<:AbstractGray} = real(eltype(C))
333335
histrange(v::AbstractArray{Gray{T}}, n::Integer) where {T} = histrange(convert(Array{Float32}, map(gray, v)), n, :right)
334336

335337
# To help type inference
336-
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))}
337338
promote_rule(::Type{T}, ::Type{C}) where {T<:Real,C<:AbstractGray} = promote_type(T, eltype(C))
338339

339340
typemin(::Type{T}) where {T<:ColorTypes.AbstractGray} = T(typemin(eltype(T)))
@@ -342,18 +343,4 @@ typemax(::Type{T}) where {T<:ColorTypes.AbstractGray} = T(typemax(eltype(T)))
342343
typemin(::T) where {T<:ColorTypes.AbstractGray} = T(typemin(eltype(T)))
343344
typemax(::T) where {T<:ColorTypes.AbstractGray} = T(typemax(eltype(T)))
344345

345-
# deprecations
346-
function Base.one(::Type{C}) where {C<:Union{TransparentGray,AbstractRGB,TransparentRGB}}
347-
Base.depwarn("one($C) will soon switch to returning 1; you might need to switch to `oneunit`", :one)
348-
C(_onetuple(C)...)
349-
end
350-
_onetuple(::Type{C}) where {C<:Colorant{T,N}} where {T,N} = ntuple(d->1, Val(N))
351-
352-
for f in (:min, :max)
353-
@eval begin
354-
@deprecate($f{T<:Gray}(x::Number, y::AbstractArray{T}), $f.(x, y))
355-
@deprecate($f{T<:Gray}(x::AbstractArray{T}, y::Number), $f.(x, y))
356-
end
357-
end
358-
359346
end

test/runtests.jl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
module ColorVectorSpaceTests
22

3+
using LinearAlgebra, Statistics
34
using ColorVectorSpace, Colors, FixedPointNumbers, StatsBase
45

56
using Test
67

8+
const var = Statistics.var
9+
710
macro test_colortype_approx_eq(a, b)
811
:(test_colortype_approx_eq($(esc(a)), $(esc(b)), $(string(a)), $(string(b))))
912
end
@@ -57,8 +60,6 @@ end
5760
@test 2.0f0*cu == Gray(2.0f0*cu.val)
5861
f = N0f8(0.5)
5962
@test (f*cu).val f*cu.val
60-
@test 2 .* cf == ccmp
61-
@test cf.*2 == ccmp
6263
@test cf/2.0f0 == Gray{Float32}(0.05)
6364
@test cu/2 == Gray(cu.val/2)
6465
@test cu/0.5f0 == Gray(cu.val/0.5f0)
@@ -89,8 +90,6 @@ end
8990
@test typeof(acu-acf) == Vector{Gray{Float32}}
9091
@test typeof(acu.+acf) == Vector{Gray{Float32}}
9192
@test typeof(acu.-acf) == Vector{Gray{Float32}}
92-
@test typeof(acu+cf) == Vector{Gray{Float32}}
93-
@test typeof(acu-cf) == Vector{Gray{Float32}}
9493
@test typeof(acu.+cf) == Vector{Gray{Float32}}
9594
@test typeof(acu.-cf) == Vector{Gray{Float32}}
9695
@test typeof(2*acf) == Vector{Gray{Float32}}
@@ -226,8 +225,6 @@ end
226225
@test_colortype_approx_eq 2.0f0*cu RGB(2.0f0*cu.r, 2.0f0*cu.g, 2.0f0*cu.b)
227226
f = N0f8(0.5)
228227
@test (f*cu).r f*cu.r
229-
@test 2 .* cf == ccmp
230-
@test cf.*2 == ccmp
231228
@test cf/2.0f0 == RGB{Float32}(0.05,0.1,0.15)
232229
@test cu/2 RGB(cu.r/2,cu.g/2,cu.b/2)
233230
@test cu/0.5f0 == RGB(cu.r/0.5f0, cu.g/0.5f0, cu.b/0.5f0)
@@ -301,8 +298,6 @@ end
301298
@test_colortype_approx_eq 2.0f0*cu RGBA(2.0f0*cu.r, 2.0f0*cu.g, 2.0f0*cu.b, 2.0f0*cu.alpha)
302299
f = N0f8(0.5)
303300
@test (f*cu).r f*cu.r
304-
@test 2 .* cf == ccmp
305-
@test cf.*2 == ccmp
306301
@test cf/2.0f0 == RGBA{Float32}(0.05,0.1,0.15,0.2)
307302
@test cu/2 == RGBA(cu.r/2,cu.g/2,cu.b/2,cu.alpha/2)
308303
@test cu/0.5f0 == RGBA(cu.r/0.5f0, cu.g/0.5f0, cu.b/0.5f0, cu.alpha/0.5f0)
@@ -380,7 +375,7 @@ end
380375
@test typemax(Gray{T}) === Gray{T}(typemax(T))
381376
@test typemin(Gray{T}(0.5)) === Gray{T}(typemin(T))
382377
@test typemax(Gray{T}(0.5)) === Gray{T}(typemax(T))
383-
A = maximum(Gray{T}.([1 0 0; 0 1 0]), 1) # see PR#44 discussion
378+
A = maximum(Gray{T}.([1 0 0; 0 1 0]); dims=1) # see PR#44 discussion
384379
@test isa(A, Matrix{Gray{T}})
385380
@test size(A) == (1,3)
386381
end

0 commit comments

Comments
 (0)