Skip to content

Display error for logarithmic quantity with arbitrary reference units #788

@kapple19

Description

@kapple19

Is the fix simple?

julia> @dB 100u"V" / 10u"V" # works and displays
20.0 dB (10 V)

julia> @dB 100u"μPa^2" / 10u"μPa^2"; # works

julia> @dB 100u"μPa^2" / 10u"μPa^2" # display is broken
Error showing value of type Level{Unitful.LogInfo{:Decibel, 10, 10}, 10 μPa^2, Quantity{Int64, 𝐌 ^2 𝐋 ^-2 𝐓 ^-4, Unitful.FreeUnits{(μPa^2,), 𝐌 ^2 𝐋 ^-2 𝐓 ^-4, nothing}}}:

SYSTEM (REPL): showing an error caused an error
ERROR: undefined behavior. Please file an issue with the code needed to reproduce.
Stacktrace:
  [1] print_response(errio::IO, response::Any, backend::Union{…}, show_value::Bool, have_color::Bool, specialdisplay::Union{…})
    @ REPL C:\Users\T0185914\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\REPL.jl:446
  [2] (::REPL.var"#70#71"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL C:\Users\T0185914\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\REPL.jl:405
  [3] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\T0185914\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\REPL.jl:678
  [4] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL C:\Users\T0185914\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\REPL.jl:403
  [5] (::REPL.var"#do_respond#100"{…})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL C:\Users\T0185914\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\REPL.jl:1035
  [6] #invokelatest#2
    @ .\essentials.jl:1055 [inlined]
  [7] invokelatest
    @ .\essentials.jl:1052 [inlined]
  [8] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Users\T0185914\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\LineEdit.jl:2755
  [9] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL C:\Users\T0185914\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\REPL.jl:1506
 [10] (::REPL.var"#79#85"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL C:\Users\T0185914\.julia\juliaup\julia-1.11.5+0.x64.w64.mingw32\share\julia\stdlib\v1.11\REPL\src\REPL.jl:497
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    logarithmiclogarithmic scales (decibels, nepers, …)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions