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

Add pretty printing for particle directions, species, and spin/pol #61

Merged
merged 2 commits into from
May 8, 2024

Conversation

AntonReinhard
Copy link
Member

Just what the title says. I want to add some pretty printing in QEDprocesses as well, and these are helpful for that. I also added jldoctests.

@AntonReinhard AntonReinhard requested a review from szabo137 May 8, 2024 18:00
@AntonReinhard
Copy link
Member Author

To stay in accordance with https://docs.julialang.org/en/v1/manual/types/#man-custom-pretty-printing , I've now only overloaded the 3-argument show function, i.e. the one used when display() is called.

julia> Electron()
electron

julia> [Electron(), Positron(), Photon()]
3-element Vector{AbstractParticleType}:
 electron
 positron
 photon

julia> print(Electron())
Electron()

Copy link
Member

@szabo137 szabo137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, looks good to me 👌

@AntonReinhard
Copy link
Member Author

One question before we merge: I added QEDbase to the docs/Project.toml by simply building the docs (to check the jldoctests). Should it be in there? I'm wondering if there's a reason it wasn't before

@szabo137
Copy link
Member

szabo137 commented May 8, 2024

One question before we merge: I added QEDbase to the docs/Project.toml by simply building the docs (to check the jldoctests). Should it be in there? I'm wondering if there's a reason it wasn't before

I think adding QEDbase to the Project.toml of the docs is correct. Currently, we use the workaround docs/make.jl:4-7, which should be removed at some point.

@AntonReinhard AntonReinhard merged commit 6f4d14a into QEDjl-project:dev May 8, 2024
4 checks passed
@AntonReinhard AntonReinhard deleted the pretty_printing branch May 8, 2024 23:56
@szabo137 szabo137 added this to the Release-next milestone May 14, 2024
szabo137 pushed a commit to QEDjl-project/QEDprocesses.jl that referenced this pull request May 21, 2024
Adds pretty printing for:
- PerturbativeQED model
- Compton process
- Coordinate systems, frames of reference, and phase space definition
- Particle stateful
- PhaseSpacePoint

Essentially, adding similar functionality to
QEDjl-project/QEDbase.jl#61 for the QEDprocesses
types.

I'm using the jldoctests to test, I'm not sure if it's really necessary
to test in a separate test as well. Putting single jldoctests for these
prints in every type definition would clutter the documentation a bit so
I've not done that. If we really want tests for each `show()` we should
probably do it in a test file.

Also, I'm not sure if there's a better way for the print functions than
alternating the `show` for objects and `print` for strings.
Interpolating doesn't work unless we also overload the `print`. (I
*think* it is print, the number of string output related functions in
Julia is confusing)
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

Successfully merging this pull request may close these issues.

2 participants