Skip to content

Commit

Permalink
keep show(LabelledUnitRange) inside LabelledNumbers
Browse files Browse the repository at this point in the history
  • Loading branch information
ogauthe committed Nov 7, 2024
1 parent 5844481 commit 64cbffb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 2 additions & 4 deletions NDTensors/src/lib/GradedAxes/src/labelledunitrangedual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ end
# fix ambiguities
Base.getindex(a::LabelledUnitRangeDual, i::Integer) = dual(nondual(a)[i])

function Base.show(
io::IO, ::MIME"text/plain", a::Union{LabelledUnitRange,LabelledUnitRangeDual}
)
function Base.show(io::IO, ::MIME"text/plain", a::LabelledUnitRangeDual)
println(io, typeof(a))
return print(io, label(a), " => ", unlabel(a))
end

function Base.show(io::IO, a::Union{LabelledUnitRange,LabelledUnitRangeDual})
function Base.show(io::IO, a::LabelledUnitRangeDual)
return print(io, nameof(typeof(a)), " ", label(a), " => ", unlabel(a))
end

Expand Down
9 changes: 9 additions & 0 deletions NDTensors/src/lib/LabelledNumbers/src/labelledunitrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,12 @@ function Base.iterate(a::LabelledUnitRange, i)
next = convert(eltype(a), labelled(i + step(a), label(a)))
return (next, next)
end

function Base.show(io::IO, ::MIME"text/plain", a::LabelledUnitRange)
println(io, typeof(a))
return print(io, label(a), " => ", unlabel(a))
end

function Base.show(io::IO, a::LabelledUnitRange)
return print(io, nameof(typeof(a)), " ", label(a), " => ", unlabel(a))
end

0 comments on commit 64cbffb

Please sign in to comment.