You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently unit printing doesn't line up the decimal point like most other Numbers do:
julia> [1.99809802u"s"2.339098; 1.02.0u"km/hr"]
2×2 Matrix{Quantity{Float64}}:1.9981 s 2.33911.02.0 km hr^-1
Thats because Unitful is missing a Base.alignment method:
help?> Base.alignment
alignment(io, X) returns a tuple (left,right) showing how many characters are needed on either side of an alignment feature such as a decimal point.
Like this:
function Base.alignment(io::IO, x::Unitful.Quantity)
# This gives us how long a Number is in show - its all on the left
length = Base.alignment_from_show(io, x)[1]
# Then get where the alignment of the parent Real:
left, right = Base.alignment(io, ustrip(x))
# Then return the left from the parent real, and the right that combines# the parents decimal places, and the printing of the units.return left, right + length - (left + right)
end
Which fixes printing:
julia> [1.99809802u"s"2.339098; 1.02.0u"km/hr"]
2×2 Matrix{Quantity{Float64}}:1.9981 s 2.33911.02.0 km hr^-1
This also fixes DimensionalData.jl printing of Unitful.jl lookups, which currently look pretty bad.
Currently unit printing doesn't line up the decimal point like most other Numbers do:
Thats because Unitful is missing a
Base.alignment
method:Like this:
Which fixes printing:
This also fixes DimensionalData.jl printing of Unitful.jl lookups, which currently look pretty bad.
See: ggebbie/OceanGreensFunctionMethods.jl#22
I don't currently have time to write up a PR and follow it through, so leaving this here if anyone else wants to, before I forget about it.
The text was updated successfully, but these errors were encountered: