From 19b5776cca43e6b6f9f36d24050c6d88183e4aa1 Mon Sep 17 00:00:00 2001 From: Chris Garling Date: Sun, 16 Feb 2025 22:58:49 -0500 Subject: [PATCH 1/2] Add docstring for `logunit` --- src/logarithm.jl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/logarithm.jl b/src/logarithm.jl index 3d679eaa..6ee8013d 100644 --- a/src/logarithm.jl +++ b/src/logarithm.jl @@ -9,6 +9,24 @@ function Base.float(x::Level{L,S}) where {L,S} return Level{L,S,typeof(v)}(v) end big(x::Level{L,S}) where {L,S} = Level{L,S}(big(x.val)) +""" + logunit(x::LogScaled) + logunit(x::Union{Type{<:LogScaled}, MixedUnits}) +Returns the units associated with a logarithmic `Quantity`, a logarithmically-scaled +`Quantity` type, or a `Quantity` type with mixed logarithmic / linear scaling. + +Examples: +```jldoctest +julia> using Unitful + +julia> logunit(1*u"dB") +dB + +julia> logunit(u"dB") +dB +``` +""" +function logunit end logunit(x::Level{L,S}) where {L,S} = MixedUnits{Level{L,S}}() logunit(x::Type{T}) where {L,S,T<:Level{L,S}} = MixedUnits{Level{L,S}}() From f927270bf298bca219e2a2b4765b00a85e7f603a Mon Sep 17 00:00:00 2001 From: Chris Garling Date: Sun, 16 Feb 2025 23:00:57 -0500 Subject: [PATCH 2/2] Add `logunit` to the API docs --- docs/src/logarithm.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/src/logarithm.md b/docs/src/logarithm.md index c773c7ed..eda7b026 100644 --- a/docs/src/logarithm.md +++ b/docs/src/logarithm.md @@ -432,6 +432,7 @@ displaying logarithmic quantities: ## API ```@docs + Unitful.logunit Unitful.linear Unitful.reflevel Unitful.uconvertp