ohno / Antique.jl

Self-contained, well-tested, well-documented Analytical Solutions of Quantum Mechanical Equations.
https://ohno.github.io/Antique.jl/
MIT License
18 stars 3 forks source link

Override display format #69

Open ohno opened 3 days ago

ohno commented 3 days ago

I want to display variable names when displaying struct. Please refer to the discourse.

Current:

julia> HO = HarmonicOscillator(k=1.0, m=1.0, ℏ=1.0)
HarmonicOscillator(1.0, 1.0, 1.0)

Goal:

julia> HO = HarmonicOscillator(k=1.0, m=1.0, ℏ=1.0)
HarmonicOscillator(k=1.0, m=1.0, ℏ=1.0)

Overwriting dump() to Base.show() is enough if we ignore executability:

julia> Base.show(io::IO,model::HarmonicOscillator) = dump(model)

julia> HO = HarmonicOscillator(k=1.0, m=1.0, ℏ=1.0)
HarmonicOscillator
  k: Float64 1.0
  m: Float64 1.0
  ℏ: Float64 1.0

In any case, this struct contains information about the variable names and their values.