Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ jobs:
- ubuntu-latest
- macOS-latest
- windows-latest
exclude:
- os: macOS-latest # Apple Silicon
version: 'min'
include:
- os: macOS-13 # Intel
version: 'min'
steps:
- uses: actions/checkout@v5
- uses: julia-actions/setup-julia@v2
Expand All @@ -42,7 +36,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }} # required
fail_ci_if_error: true
file: ./lcov.info
files: ./lcov.info
flags: unittests
docs:
name: Documentation
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "SpecialFunctions"
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
version = "2.5.1"
version = "2.6.0"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand All @@ -22,7 +22,7 @@ IrrationalConstants = "0.1, 0.2"
LogExpFunctions = "0.3.2"
OpenLibm_jll = "0.7, 0.8"
OpenSpecFun_jll = "0.5"
julia = "1.5"
julia = "1.10"

[extras]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
15 changes: 4 additions & 11 deletions src/SpecialFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ include("gamma.jl")
include("gamma_inc.jl")
include("betanc.jl")
include("beta_inc.jl")
if !isdefined(Base, :get_extension)
include("../ext/SpecialFunctionsChainRulesCoreExt.jl")
end
include("deprecated.jl")

for f in (:digamma, :erf, :erfc, :erfcinv, :erfcx, :erfi, :erfinv, :logerfc, :logerfcx,
Expand All @@ -119,13 +116,9 @@ for f in (:beta, :lbeta)
end
polygamma(m::Integer, x::Missing) = missing

# In future just use `fastabs` from Base.Math
# https://github.com/JuliaLang/julia/blob/93fb785831dcfcc442f82fab8746f0244c5274ae/base/special/trig.jl#L1057
if isdefined(Base.Math, :fastabs)
import Base.Math: fastabs
else
fastabs(x::Number) = abs(x)
fastabs(x::Complex) = abs(real(x)) + abs(imag(x))
end
Comment on lines -122 to -129
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since fastabs is technically not public, maybe it's safer to keep this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... maybe. Codecov was complaining (correctly) that these lines are not covered by tests anymore. So in that sense technically the fallback is not safe either as it's untested when dropping support for Julia < 1.10.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the better approach would be to mark Base.Math.fastabs as public?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but good luck with that 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from making Base.Math.fastabs public, the only other "correct" approach would be to only define it in SpecialFunctions, ie to only keep the second branch. Then we would neither rely on internals nor on untested code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe that's not too bad, it's two very simple methods, and unlikely to need maintenance.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I removed the first branch 🙂

# `fastabs` is identical to `Base.Math.fastabs` which is not used here since it is not public
# https://github.com/JuliaLang/julia/blob/93fb785831dcfcc442f82fab8746f0244c5274ae/base/special/trig.jl#L1057
fastabs(x::Number) = abs(x)
fastabs(x::Complex) = abs(real(x)) + abs(imag(x))

end # module
16 changes: 4 additions & 12 deletions src/gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function _digamma(z::ComplexOrReal{Float64})
# argument," Computer Phys. Commun. vol. 4, pp. 221–226 (1972).
x = real(z)
if x <= 0 # reflection formula
ψ = -π * _cotpi(z)
ψ = -π / tanpi(z)
z = 1 - z
x = real(z)
else
Expand Down Expand Up @@ -55,13 +55,6 @@ function _digamma(x::BigFloat)
return z
end

"""
_cotpi(x) = cot(π * x)

Accurate for integer arguments
"""
_cotpi(x) = @static VERSION >= v"1.10.0-DEV.525" ? inv(tanpi(x)) : cospi(x) / sinpi(x)

"""
trigamma(x)

Expand Down Expand Up @@ -139,12 +132,12 @@ const cotderiv_Q = [cotderiv_q(m) for m in 1:100]
function cotderiv(m::Integer, z)
isinf(imag(z)) && return zero(z)
if m <= 0
m == 0 && return π * _cotpi(z)
m == 0 && return π / tanpi(z)
throw(DomainError(m, "`m` must be nonnegative."))
end
if m <= length(cotderiv_Q)
q = cotderiv_Q[m]
x = _cotpi(z)
x = inv(tanpi(z))
y = x*x
s = q[1] + q[2] * y
t = y
Expand Down Expand Up @@ -816,8 +809,7 @@ function logabsbeta(a::T, b::T) where T<:Real
if a <= 0 && isinteger(a)
if a + b <= 0 && isinteger(b)
r = logbeta(1 - a - b, b)
# in julia ≥ 1.7, iseven doesn't require Int (julia#38976)
sgn = iseven(@static VERSION ≥ v"1.7" ? b : Int(b)) ? 1 : -1
sgn = iseven(b) ? 1 : -1
return r, sgn
else
return -log(zero(a)), 1
Expand Down