Skip to content

Commit

Permalink
Merge pull request #145 from gdalle/gd/printing
Browse files Browse the repository at this point in the history
Allow printing of arbitrary Particles
  • Loading branch information
baggepinnen committed Aug 8, 2024
2 parents dc7deeb + 6f57a41 commit d0ea922
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/particles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Return a short string describing the type
"""
shortform(p::Particles) = "Part"
shortform(p::StaticParticles) = "SPart"
function to_num_str(p::AbstractParticles{T}, d=3, ds=d-1) where T
function to_num_str(p::AbstractParticles{T}, d=3, ds=d-1) where {T<:Union{Number,AbstractArray}}
s = pstd(p)
# TODO: be smart and select sig digits based on s
if T <: AbstractFloat && s < eps(p)
Expand All @@ -110,6 +110,7 @@ function to_num_str(p::AbstractParticles{T}, d=3, ds=d-1) where T
string(round(pmean(p), sigdigits=d), " ± ", round(s, sigdigits=ds))
end
end
to_num_str(p::AbstractParticles{T}, d, ds) where T = ""


function Base.show(io::IO, p::AbstractParticles{T,N}) where {T,N}
Expand Down Expand Up @@ -706,4 +707,4 @@ function particle_dict2dict_vec(dict)
map(1:N) do i
Dict(k => vecindex(v, i) for (k, v) in dict)
end
end
end

0 comments on commit d0ea922

Please sign in to comment.