Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove DocStringExtensions dependency #84

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ version = "0.3.28"
[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ChangesOfVariables = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
IrrationalConstants = "92d709cd-6900-40b7-9082-c6be49f344b6"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -24,7 +23,6 @@ LogExpFunctionsInverseFunctionsExt = "InverseFunctions"
[compat]
ChainRulesCore = "1"
ChangesOfVariables = "0.1"
DocStringExtensions = "0.8, 0.9"
InverseFunctions = "0.1"
IrrationalConstants = "0.1, 0.2"
julia = "1"
@@ -33,8 +31,8 @@ julia = "1"
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
ChangesOfVariables = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1 change: 0 additions & 1 deletion src/LogExpFunctions.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module LogExpFunctions

using DocStringExtensions: SIGNATURES
using Base: Math.@horner

import IrrationalConstants
48 changes: 24 additions & 24 deletions src/basicfuns.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# scalar functions
"""
$(SIGNATURES)
xlogx(x)

Return `x * log(x)` for `x ≥ 0`, handling ``x = 0`` by taking the downward limit.

@@ -15,7 +15,7 @@ function xlogx(x::Number)
end

"""
$(SIGNATURES)
xlogy(x, y)

Return `x * log(y)` for `y > 0` with correct limit at ``x = 0``.

@@ -30,7 +30,7 @@ function xlogy(x::Number, y::Number)
end

"""
$(SIGNATURES)
xlog1py(x, y)

Return `x * log(1 + y)` for `y ≥ -1` with correct limit at ``x = 0``.

@@ -45,7 +45,7 @@ function xlog1py(x::Number, y::Number)
end

"""
$(SIGNATURES)
xexpx(x)

Return `x * exp(x)` for `x > -Inf`, or zero if `x == -Inf`.

@@ -60,7 +60,7 @@ function xexpx(x::Real)
end

"""
$(SIGNATURES)
xexpy(x, y)

Return `x * exp(y)` for `y > -Inf`, or zero if `y == -Inf` or if `x == 0` and `y` is finite.

@@ -90,7 +90,7 @@ end
@inline _logistic_bounds(x::Float64) = (-744.4400719213812, 36.7368005696771)

"""
$(SIGNATURES)
logistic(x)

The [logistic](https://en.wikipedia.org/wiki/Logistic_function) sigmoid function mapping a
real number to a value in the interval ``[0,1]``,
@@ -110,7 +110,7 @@ function logistic(x::Union{Float16, Float32, Float64})
end

"""
$(SIGNATURES)
logit(x)

The [logit](https://en.wikipedia.org/wiki/Logit) or log-odds transformation, defined as
```math
@@ -123,7 +123,7 @@ Its inverse is the [`logistic`](@ref) function.
logit(x::Real) = log(x / (one(x) - x))

"""
$(SIGNATURES)
logcosh(x)

Return `log(cosh(x))`, carefully evaluated without intermediate calculation of `cosh(x)`.

@@ -135,7 +135,7 @@ function logcosh(x::Real)
end

"""
$(SIGNATURES)
logabssinh(x)

Return `log(abs(sinh(x)))`, carefully evaluated without intermediate calculation of `sinh(x)`.

@@ -147,7 +147,7 @@ function logabssinh(x::Real)
end

"""
$(SIGNATURES)
log1psq(x)

Return `log(1+x^2)` evaluated carefully for `abs(x)` very small or very large.
"""
@@ -158,7 +158,7 @@ function log1psq(x::Union{Float32,Float64})
end

"""
$(SIGNATURES)
log1pexp(x)

Return `log(1+exp(x))` evaluated carefully for largish `x`.

@@ -222,7 +222,7 @@ each time. Also, _log1pexp_thresholds is not elided by the compiler in Julia 1.0
@inline _log1pexp_thresholds(::Float16) = (Float16(-17.33), Float16(-7.625), Float16(3.467), Float16(5.86))

"""
$(SIGNATURES)
log1mexp(x)

Return `log(1 - exp(x))`

@@ -242,14 +242,14 @@ function log1mexp(x::Real)
end

"""
$(SIGNATURES)
log2mexp(x)

Return `log(2 - exp(x))` evaluated as `log1p(-expm1(x))`
"""
log2mexp(x::Real) = log1p(-_expm1(x))

"""
$(SIGNATURES)
logexpm1(x)

Return `log(exp(x) - 1)` or the “invsoftplus” function. It is the inverse of
[`log1pexp`](@ref) (aka “softplus”).
@@ -261,7 +261,7 @@ const softplus = log1pexp
const invsoftplus = logexpm1

"""
$(SIGNATURES)
log1pmx(x)

Return `log(1 + x) - x`.

@@ -292,7 +292,7 @@ end
log1pmx(x::Real) = log1p(x) - x

"""
$(SIGNATURES)
logmxp1(x)

Return `log(x) - x + 1` carefully evaluated.
This will fall back to the naive calculation for argument types different from `Float64`.
@@ -342,7 +342,7 @@ end


"""
$(SIGNATURES)
logaddexp(x, y)

Return `log(exp(x) + exp(y))`, avoiding intermediate overflow/undeflow, and handling
non-finite values.
@@ -365,7 +365,7 @@ end
Base.@deprecate logsumexp(x::Real, y::Real) logaddexp(x, y)

"""
$(SIGNATURES)
logsubexp(x, y)

Return `log(abs(exp(x) - exp(y)))`, preserving numerical accuracy.
"""
@@ -429,14 +429,14 @@ function _softmax!(r, x, dims)
end

"""
$(SIGNATURES)
cloglog(x)

Compute the complementary log-log, `log(-log(1 - x))`.
"""
cloglog(x) = log(-log1p(-x))

"""
$(SIGNATURES)
cexpexp(x)

Compute the complementary double exponential, `1 - exp(-exp(x))`.
"""
@@ -448,7 +448,7 @@ this uses the identity:
log(logistic(x)) = -log(1 + exp(-x))
=#
"""
$(SIGNATURES)
loglogistic(x)

Return `log(logistic(x))`, computed more carefully and with fewer calls
than the naive composition of functions.
@@ -463,7 +463,7 @@ this uses the identity:
logit(exp(x)) = log(exp(x) / (1 + exp(x))) = -log(exp(-x) - 1)
=#
"""
$(SIGNATURES)
logitexp(x)

Return `logit(exp(x))`, computed more carefully and with fewer calls than
the naive composition of functions.
@@ -481,7 +481,7 @@ that is, negation in the log-odds domain.
=#

"""
$(SIGNATURES)
log1mlogistic(x)

Return `log(1 - logistic(x))`, computed more carefully and with fewer calls than
the naive composition of functions.
@@ -498,7 +498,7 @@ this uses the same identity:
=#

"""
$(SIGNATURES)
logit1mexp(x)

Return `logit(1 - exp(x))`, computed more carefully and with fewer calls than
the naive composition of functions.
6 changes: 3 additions & 3 deletions src/logsumexp.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
$(SIGNATURES)
logsumexp(X)

Compute `log(sum(exp, X))`.

@@ -15,7 +15,7 @@ See also [`logsumexp!`](@ref).
logsumexp(X) = _logsumexp_onepass(X)

"""
$(SIGNATURES)
logsumexp(X; dims)

Compute `log.(sum(exp.(X); dims=dims))`.

@@ -30,7 +30,7 @@ See also [`logsumexp!`](@ref).
logsumexp(X::AbstractArray{<:Number}; dims=:) = _logsumexp(X, dims)

"""
$(SIGNATURES)
logsumexp!(out, X)

Compute [`logsumexp`](@ref) of `X` over the singleton dimensions of `out`, and write results to `out`.