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

Base.show(io::IO, x::Level) error #766

Open
giopaglia opened this issue Jan 28, 2025 · 0 comments
Open

Base.show(io::IO, x::Level) error #766

giopaglia opened this issue Jan 28, 2025 · 0 comments

Comments

@giopaglia
Copy link

giopaglia commented Jan 28, 2025

Hi, thank you for this wonderful package!

Here's the thing, I can construct a Level:

y = Unitful.Level{Unitful.Decibel,1}(2);

But I can't show it:

julia> y
Error showing value of type Level{Unitful.LogInfo{:Decibel, 10, 10}, 1, Int64}:
ERROR: undefined behavior. Please file an issue with the code needed to reproduce.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] isrootpower_dim(y::Unitful.Dimensions{()})
    @ Unitful ~/.julia/packages/Unitful/dHMk1/src/logarithm.jl:167
  [3] isrootpower(y::Int64)
    @ Unitful ~/.julia/packages/Unitful/dHMk1/src/logarithm.jl:166
  [4] tolog(L::Type{Unitful.LogInfo{:Decibel, 10, 10}}, S::Int64, x::Float64)
    @ Unitful ~/.julia/packages/Unitful/dHMk1/src/logarithm.jl:82
  [5] ustrip(x::Level{Unitful.LogInfo{:Decibel, 10, 10}, 1, Int64})
    @ Unitful ~/.julia/packages/Unitful/dHMk1/src/logarithm.jl:162
  [6] show(io::IOContext{Base.TTY}, x::Level{Unitful.LogInfo{:Decibel, 10, 10}, 1, Int64})
    @ Unitful ~/.julia/packages/Unitful/dHMk1/src/logarithm.jl:314
  [7] show(io::IOContext{Base.TTY}, ::MIME{Symbol("text/plain")}, x::Level{Unitful.LogInfo{:Decibel, 10, 10}, 1, Int64})
    @ Base.Multimedia ./multimedia.jl:47
...

A similar issue exists with:

x1 = @dB (-2u"V")/1u"V";

where I can construct it, but cannot show it.
Here, the issue is probably due to logarithmic scales not allowing negative values. In fact, this works perfectly:

julia> x2 = @dB (2u"V")/1u"V"
6.020599913279624 dBV

But then, the issue is that that x1 construction shouldn´t probably be allowed at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant