Skip to content

Commit

Permalink
remove doublets
Browse files Browse the repository at this point in the history
  • Loading branch information
ogauthe committed Oct 31, 2024
1 parent c57bc02 commit 032bde4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
5 changes: 0 additions & 5 deletions NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ function space_isequal(a1::AbstractUnitRange, a2::AbstractUnitRange)
return (isdual(a1) == isdual(a2)) && labelled_isequal(a1, a2)
end

# TODO: See if this is needed.
function Base.AbstractUnitRange{T}(a::GradedOneTo{<:LabelledInteger{T}}) where {T}
return unlabel_blocks(a)
end

# TODO: Use `TypeParameterAccessors`.
Base.eltype(::Type{<:GradedUnitRange{T}}) where {T} = T

Expand Down
24 changes: 1 addition & 23 deletions NDTensors/src/lib/GradedAxes/src/gradedunitrangedual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ Base.step(a::GradedUnitRangeDual) = label_dual(step(nondual(a)))

Base.view(a::GradedUnitRangeDual, index::Block{1}) = a[index]

function Base.show(io::IO, a::GradedUnitRangeDual)
return print(io, GradedUnitRangeDual, "(", blocklasts(a), ")")
end

function Base.show(io::IO, mimetype::MIME"text/plain", a::GradedUnitRangeDual)
return Base.invoke(
show, Tuple{typeof(io),MIME"text/plain",AbstractArray}, io, mimetype, a
)
end

function Base.getindex(a::GradedUnitRangeDual, indices::AbstractUnitRange{<:Integer})
return dual(getindex(nondual(a), indices))
end
Expand Down Expand Up @@ -88,10 +78,7 @@ function BlockArrays.BlockSlice(b::Block, r::GradedUnitRangeDual)
return BlockSlice(b, dual(r))
end

using NDTensors.LabelledNumbers: LabelledNumbers, label
LabelledNumbers.label(a::GradedUnitRangeDual) = dual(label(nondual(a)))

using NDTensors.LabelledNumbers: LabelledUnitRange
using NDTensors.LabelledNumbers: LabelledNumbers, LabelledUnitRange, label
# The Base version of `length(::AbstractUnitRange)` drops the label.
function Base.length(a::GradedUnitRangeDual{<:Any,<:LabelledUnitRange})
return dual(length(nondual(a)))
Expand Down Expand Up @@ -131,15 +118,6 @@ function Base.OrdinalRange{Int,Int}(
return unlabel(nondual(r))
end

# This is only needed in certain Julia versions below 1.10
# (for example Julia 1.6).
# TODO: Delete this once we drop Julia 1.6 support.
# The type constraint `T<:Integer` is needed to avoid an ambiguity
# error with a conversion method in Base.
function Base.UnitRange{T}(a::GradedUnitRangeDual{<:LabelledInteger{T}}) where {T<:Integer}
return UnitRange{T}(nondual(a))
end

function unlabel_blocks(a::GradedUnitRangeDual)
return unlabel_blocks(nondual(a))
end

0 comments on commit 032bde4

Please sign in to comment.