From 012754f27f197973e16230d80508aeec81e3cf62 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Thu, 4 Mar 2021 04:37:22 -0600 Subject: [PATCH] Fix SpecialFunctions depwarns xref https://github.com/JuliaGraphics/ColorVectorSpace.jl/issues/106#issuecomment-790484474 --- Project.toml | 4 ++-- src/ColorVectorSpace.jl | 12 ++++++++---- test/runtests.jl | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index f118cbe..3bddbc7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ColorVectorSpace" uuid = "c3611d14-8923-5661-9e6a-0046d554d3a4" -version = "0.9.1" +version = "0.9.2" [deps] ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" @@ -13,7 +13,7 @@ TensorCore = "62fd8b95-f654-4bbd-a8a5-9c27f68ccd50" [compat] ColorTypes = "0.10" FixedPointNumbers = "0.8" -SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1" +SpecialFunctions = "0.9, 0.10, 1" TensorCore = "0.1" julia = "1" diff --git a/src/ColorVectorSpace.jl b/src/ColorVectorSpace.jl index 92a5e93..a42c02a 100644 --- a/src/ColorVectorSpace.jl +++ b/src/ColorVectorSpace.jl @@ -23,7 +23,7 @@ import Base: conj, sin, cos, tan, sinh, cosh, tanh, exp2, exp10, expm1, cbrt, sqrt, significand, frexp, modf import LinearAlgebra: norm, ⋅, dot, promote_leaf_eltypes # norm1, norm2, normInf -import SpecialFunctions: gamma, lgamma, lfact +import SpecialFunctions: gamma, logabsgamma, lfact using Statistics import Statistics: middle, _mean_promote @@ -213,17 +213,21 @@ const unaryOps = (:~, :conj, :abs, :asind, :atand, :rad2deg, :deg2rad, :log, :log2, :log10, :log1p, :exponent, :exp, :exp2, :exp10, :expm1, :cbrt, :sqrt, - :significand, :lgamma, + :significand, :gamma, :lfact, :frexp, :modf, :(SpecialFunctions.erf), :(SpecialFunctions.erfc), :(SpecialFunctions.erfcx), :(SpecialFunctions.erfi), :(SpecialFunctions.dawson), - :(SpecialFunctions.airy), :(SpecialFunctions.airyai), - :(SpecialFunctions.airyprime), :(SpecialFunctions.airyaiprime), :(SpecialFunctions.airybi), :(SpecialFunctions.airybiprime), + :(SpecialFunctions.airyai), + :(SpecialFunctions.airyaiprime), :(SpecialFunctions.airybi), :(SpecialFunctions.airybiprime), :(SpecialFunctions.besselj0), :(SpecialFunctions.besselj1), :(SpecialFunctions.bessely0), :(SpecialFunctions.bessely1), :(SpecialFunctions.eta), :(SpecialFunctions.zeta), :(SpecialFunctions.digamma)) for op in unaryOps @eval ($op)(c::AbstractGray) = Gray($op(gray(c))) end +function logabsgamma(c::AbstractGray) + lagc, s = logabsgamma(gray(c)) + return Gray(lagc), s +end middle(c::AbstractGray) = arith_colorant_type(c)(middle(gray(c))) middle(x::C, y::C) where {C<:AbstractGray} = arith_colorant_type(C)(middle(gray(x), gray(y))) diff --git a/test/runtests.jl b/test/runtests.jl index 3eb1d02..1120e63 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -226,6 +226,7 @@ ColorTypes.blue(c::RatRGB) = c.b end end @test ntested > 130 + @test logabsgamma(Gray(0.2)) == (Gray(logabsgamma(0.2)[1]), 1) for g in (Gray{N0f8}(0.4), Gray{N0f8}(0.6)) for op in (:trunc, :floor, :round, :ceil) v = @eval $op(Bool, gray($g))