Skip to content
Open
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
1 change: 1 addition & 0 deletions src/logarithm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ end

ustrip(x::Level{L,S}) where {L<:LogInfo,S} = tolog(L,S,x.val/reflevel(x))
ustrip(x::Gain) = x.val
ustrip(u::MixedUnits, x) = ustrip(uconvert(u, x))

isrootpower(y::IsRootPowerRatio{T}) where {T} = T
isrootpower(y) = isrootpower_dim(dimension(y))
Expand Down
8 changes: 7 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Unitful:
ms, s, minute, hr, d, yr, Hz,
J, A, N, mol, V,
mW, W,
dB, dB_rp, dB_p, dBm, dBV, dBSPL, Decibel,
dB, B, dB_rp, dB_p, dBm, dBV, dBμV, dBSPL, Decibel,
Np, Np_rp, Np_p, Neper,
C

Expand Down Expand Up @@ -103,6 +103,8 @@ end
@test @inferred(ustrip(3*FixedUnits(m))) === 3
@test @inferred(ustrip(3)) === 3
@test @inferred(ustrip(3.0m)) === 3.0
@test @inferred(ustrip(3.0dB)) === 3.0
@test @inferred(ustrip(3.0dBm)) === 3.0
# ustrip with type and unit arguments
@test @inferred(ustrip(m, 3.0m)) === 3.0
@test @inferred(ustrip(m, 2mm)) === 1//500
Expand All @@ -116,6 +118,10 @@ end
@test @inferred(ustrip(Int, mm, 2.0m)) === 2000
@test @inferred(ustrip(Float32, NoUnits, 5.0u"m"/2.0u"m")) === Float32(2.5)
@test @inferred(ustrip(Int, NoUnits, 3.0u"m"/1.0u"cm")) === 300
@test @inferred(ustrip(B, 3.0dB)) === 0.3
@test @inferred(ustrip(dBμV, 3.0dBV)) === 123.0
@test_throws DimensionError ustrip(dBm, 3.0dBμV)
@test @inferred(ustrip(B/m, 1.0dB/mm)) ≈ 100.0
# convert
@test convert(typeof(1mm/m), 3) == 3000mm/m
@test convert(typeof(1mm/m), 3*NoUnits) == 3000mm/m
Expand Down