diff --git a/.travis.yml b/.travis.yml index d03cab7..a766d1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ os: - linux - osx julia: - - 0.6 - nightly notifications: email: false diff --git a/REQUIRE b/REQUIRE index f607aca..b390882 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,7 +1,6 @@ -julia 0.6 +julia 0.7.0-beta.85 Colors 0.7.1 ColorTypes 0.6.3 FixedPointNumbers 0.3.0 StatsBase 0.8.2 -Compat 0.18.0 SpecialFunctions diff --git a/appveyor.yml b/appveyor.yml index 3c89917..9fe53b2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,5 @@ environment: matrix: - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe" - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe" - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe" - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" diff --git a/src/ColorVectorSpace.jl b/src/ColorVectorSpace.jl index 0f42320..ff17925 100644 --- a/src/ColorVectorSpace.jl +++ b/src/ColorVectorSpace.jl @@ -2,14 +2,17 @@ __precompile__(true) module ColorVectorSpace -using Colors, FixedPointNumbers, SpecialFunctions, Compat -import StatsBase: histrange +using Colors, FixedPointNumbers, SpecialFunctions import Base: ==, +, -, *, /, ^, <, ~ import Base: abs, abs2, clamp, convert, copy, div, eps, isfinite, isinf, - isnan, isless, length, mapreduce, norm, oneunit, promote_array_type, + isnan, isless, length, mapreduce, oneunit, promote_op, promote_rule, zero, trunc, floor, round, ceil, bswap, - mod, rem, atan2, hypot, max, min, varm, real, typemin, typemax + mod, rem, atan2, hypot, max, min, real, typemin, typemax +import LinearAlgebra: norm +import StatsBase: histrange, varm +import SpecialFunctions: gamma, lgamma, lfact +import Statistics: middle export nan @@ -23,9 +26,9 @@ import Base: conj, sin, cos, tan, sinh, cosh, tanh, asind, atand, rad2deg, deg2rad, log, log2, log10, log1p, exponent, exp, exp2, expm1, cbrt, sqrt, - significand, lgamma, - gamma, lfact, frexp, modf, - float, middle + significand, + frexp, modf, + float export dotc @@ -60,14 +63,9 @@ end for f in (:trunc, :floor, :round, :ceil, :eps, :bswap) @eval $f(g::Gray{T}) where {T} = Gray{T}($f(gray(g))) - @eval Compat.@dep_vectorize_1arg Gray $f end eps(::Type{Gray{T}}) where {T} = Gray(eps(T)) -Compat.@dep_vectorize_1arg AbstractGray isfinite -Compat.@dep_vectorize_1arg AbstractGray isinf -Compat.@dep_vectorize_1arg AbstractGray isnan -Compat.@dep_vectorize_1arg AbstractGray abs -Compat.@dep_vectorize_1arg AbstractGray abs2 + for f in (:trunc, :floor, :round, :ceil) @eval $f(::Type{T}, g::Gray) where {T<:Integer} = Gray{T}($f(T, gray(g))) end @@ -274,7 +272,7 @@ function Base.isapprox(x::AbstractArray{Cx}, y::AbstractArray{Cy}; rtol::Real=Base.rtoldefault(eltype(Cx),eltype(Cy),0), atol::Real=0, - norm::Function=vecnorm) where {Cx<:MathTypes,Cy<:MathTypes} + norm::Function=norm) where {Cx<:MathTypes,Cy<:MathTypes} d = norm(x - y) if isfinite(d) return d <= atol + rtol*max(norm(x), norm(y)) @@ -293,16 +291,8 @@ dotc(x::AbstractGray, y::AbstractGray) = dotc(promote(x, y)...) float(::Type{T}) where {T<:Gray} = typeof(float(zero(T))) # Mixed types -if VERSION < v"0.7.0-DEV.2138" - (+)(a::MathTypes, b::MathTypes) = (+)(Base.promote_noncircular(a, b)...) - (-)(a::MathTypes, b::MathTypes) = (-)(Base.promote_noncircular(a, b)...) -else - (+)(a::MathTypes, b::MathTypes) = (+)(promote(a, b)...) - (-)(a::MathTypes, b::MathTypes) = (-)(promote(a, b)...) -end - -Compat.@dep_vectorize_2arg Gray max -Compat.@dep_vectorize_2arg Gray min +(+)(a::MathTypes, b::MathTypes) = (+)(promote(a, b)...) +(-)(a::MathTypes, b::MathTypes) = (-)(promote(a, b)...) # Arrays +(A::AbstractArray{C}) where {C<:MathTypes} = A @@ -345,7 +335,6 @@ real(::Type{C}) where {C<:AbstractGray} = real(eltype(C)) histrange(v::AbstractArray{Gray{T}}, n::Integer) where {T} = histrange(convert(Array{Float32}, map(gray, v)), n, :right) # To help type inference -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))} promote_rule(::Type{T}, ::Type{C}) where {T<:Real,C<:AbstractGray} = promote_type(T, eltype(C)) typemin(::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))) typemin(::T) where {T<:ColorTypes.AbstractGray} = T(typemin(eltype(T))) typemax(::T) where {T<:ColorTypes.AbstractGray} = T(typemax(eltype(T))) -# deprecations -function Base.one(::Type{C}) where {C<:Union{TransparentGray,AbstractRGB,TransparentRGB}} - Base.depwarn("one($C) will soon switch to returning 1; you might need to switch to `oneunit`", :one) - C(_onetuple(C)...) -end -_onetuple(::Type{C}) where {C<:Colorant{T,N}} where {T,N} = ntuple(d->1, Val(N)) - -for f in (:min, :max) - @eval begin - @deprecate($f{T<:Gray}(x::Number, y::AbstractArray{T}), $f.(x, y)) - @deprecate($f{T<:Gray}(x::AbstractArray{T}, y::Number), $f.(x, y)) - end -end - end diff --git a/test/REQUIRE b/test/REQUIRE index 1e481e7..bf563d9 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -1,2 +1 @@ -BaseTestNext StatsBase diff --git a/test/runtests.jl b/test/runtests.jl index c2ca842..71e64d7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,8 +1,11 @@ module ColorVectorSpaceTests -using ColorVectorSpace, Colors, FixedPointNumbers, Compat, StatsBase +using LinearAlgebra, Statistics +using ColorVectorSpace, Colors, FixedPointNumbers, StatsBase -using Base.Test +using Test + +const var = Statistics.var macro test_colortype_approx_eq(a, b) :(test_colortype_approx_eq($(esc(a)), $(esc(b)), $(string(a)), $(string(b)))) @@ -57,8 +60,6 @@ end @test 2.0f0*cu == Gray(2.0f0*cu.val) f = N0f8(0.5) @test (f*cu).val ≈ f*cu.val - @test 2 .* cf == ccmp - @test cf.*2 == ccmp @test cf/2.0f0 == Gray{Float32}(0.05) @test cu/2 == Gray(cu.val/2) @test cu/0.5f0 == Gray(cu.val/0.5f0) @@ -89,8 +90,6 @@ end @test typeof(acu-acf) == Vector{Gray{Float32}} @test typeof(acu.+acf) == Vector{Gray{Float32}} @test typeof(acu.-acf) == Vector{Gray{Float32}} - @test typeof(acu+cf) == Vector{Gray{Float32}} - @test typeof(acu-cf) == Vector{Gray{Float32}} @test typeof(acu.+cf) == Vector{Gray{Float32}} @test typeof(acu.-cf) == Vector{Gray{Float32}} @test typeof(2*acf) == Vector{Gray{Float32}} @@ -161,6 +160,7 @@ end v = @eval $op(gray(g)) # if this fails, don't bother @show op @test op(g) == v + catch end end end @@ -225,8 +225,6 @@ end @test_colortype_approx_eq 2.0f0*cu RGB(2.0f0*cu.r, 2.0f0*cu.g, 2.0f0*cu.b) f = N0f8(0.5) @test (f*cu).r ≈ f*cu.r - @test 2 .* cf == ccmp - @test cf.*2 == ccmp @test cf/2.0f0 == RGB{Float32}(0.05,0.1,0.15) @test cu/2 ≈ RGB(cu.r/2,cu.g/2,cu.b/2) @test cu/0.5f0 == RGB(cu.r/0.5f0, cu.g/0.5f0, cu.b/0.5f0) @@ -300,8 +298,6 @@ end @test_colortype_approx_eq 2.0f0*cu RGBA(2.0f0*cu.r, 2.0f0*cu.g, 2.0f0*cu.b, 2.0f0*cu.alpha) f = N0f8(0.5) @test (f*cu).r ≈ f*cu.r - @test 2 .* cf == ccmp - @test cf.*2 == ccmp @test cf/2.0f0 == RGBA{Float32}(0.05,0.1,0.15,0.2) @test cu/2 == RGBA(cu.r/2,cu.g/2,cu.b/2,cu.alpha/2) @test cu/0.5f0 == RGBA(cu.r/0.5f0, cu.g/0.5f0, cu.b/0.5f0, cu.alpha/0.5f0) @@ -379,7 +375,7 @@ end @test typemax(Gray{T}) === Gray{T}(typemax(T)) @test typemin(Gray{T}(0.5)) === Gray{T}(typemin(T)) @test typemax(Gray{T}(0.5)) === Gray{T}(typemax(T)) - A = maximum(Gray{T}.([1 0 0; 0 1 0]), 1) # see PR#44 discussion + A = maximum(Gray{T}.([1 0 0; 0 1 0]); dims=1) # see PR#44 discussion @test isa(A, Matrix{Gray{T}}) @test size(A) == (1,3) end