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

Improve show (e.g. show value with dual numbers) #80

Open
briochemc opened this issue Sep 10, 2018 · 3 comments
Open

Improve show (e.g. show value with dual numbers) #80

briochemc opened this issue Sep 10, 2018 · 3 comments

Comments

@briochemc
Copy link

briochemc commented Sep 10, 2018

Is it on purpose that values of complex or dual types are not shown? (But arrays of those element types are shown?)
MWE (v0.7):

using Parameters, DualNumbers
@with_kw struct Para
    a = 0.0
    b = 0.0 + im
    c = 0.0 + ε
    d = zeros(2) .+ im
    e = zeros(2) .+ ε
end
Para()

Output (added comments are mine):

julia> Para()
Para
  a: Float64 0.0
  b: Complex{Float64}                    # no value shown?
  c: Dual{Float64}                       # no value shown?
  d: Array{Complex{Float64}}((2,)) Complex{Float64}[0.0+1.0im, 0.0+1.0im]
  e: Array{Dual{Float64}}((2,)) Dual{Float64}[0.0+1.0ɛ, 0.0+1.0ɛ]
@mauro3
Copy link
Owner

mauro3 commented Sep 10, 2018

That's not good. As a quick work-around you can use the @with_kw_noshow.

Related, I think the printing should leave away the types of the fields.

@cstjean
Copy link
Contributor

cstjean commented Oct 16, 2018

Yes, printing just the values without the types would be much nicer. With Unitful:

julia> AAA(a=1.0u"m/s", b=2)
AAA
  a: Quantity{Float64,Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1), Unitful.Dimension{:Time}(-1//1))},Unitful.FreeUnits{(Unitful.Unit{:Meter,Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1),)}}(0, 1//1), Unitful.Unit{:Second,Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)}}(0, -1//1)),Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1), Unitful.Dimension{:Time}(-1//1))}}}
  b: Int64 2

@mauro3
Copy link
Owner

mauro3 commented Jan 25, 2019

I just use dump for the printing (with maxdepth=1). A custom rolled printer would be great. Alternatively increasing maxdepth would yield:

julia> dump(Para(),maxdepth=2)
Para
  a: Float64 0.0
  b: Complex{Float64}
    re: Float64 0.0
    im: Float64 1.0

which isn't great either.

@mauro3 mauro3 changed the title Show value with dual numbers Improve show (e.g. show value with dual numbers) Nov 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants