Skip to content

Commit

Permalink
Fix complex value ranges and affine StepRangeLen.
Browse files Browse the repository at this point in the history
  • Loading branch information
contradict committed Mar 8, 2023
1 parent e2a504d commit d91f45a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function show(io::IO, mime::MIME"text/plain", x::Quantity)
end
end

function show(io::IO, mime::MIME"text/plain", r::Union{StepRange{T},StepRangeLen{T}}) where T<:Quantity
function show(io::IO, mime::MIME"text/plain", r::StepRange{T}) where T<:Quantity
a,s,b = first(r), step(r), last(r)
U = unit(a)
V = absoluteunit(U)
Expand All @@ -132,6 +132,17 @@ function show(io::IO, mime::MIME"text/plain", r::Union{StepRange{T},StepRangeLen
show(io, mime, U)
end

function show(io::IO, mime::MIME"text/plain", r::StepRangeLen{T}) where T<:Quantity
a,s,b = first(r), step(r), last(r)
U = unit(a)
V = absoluteunit(U)
print(io, '(')
show(io, mime, StepRangeLen(ustrip(U, a), ustrip(V, s), length(r)))
print(io, ')')
has_unit_spacing(U) && print(io,' ')
show(io, mime, U)
end

function show(io::IO, ::MIME"text/plain", x::typeof(NoDims))
print(io, "NoDims")
end
Expand Down

0 comments on commit d91f45a

Please sign in to comment.