Skip to content

Commit

Permalink
Base.AbstractUnitRange actually needed
Browse files Browse the repository at this point in the history
  • Loading branch information
ogauthe committed Nov 1, 2024
1 parent e716903 commit 9796676
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ function space_isequal(a1::AbstractUnitRange, a2::AbstractUnitRange)
return (isdual(a1) == isdual(a2)) && labelled_isequal(a1, a2)
end

# needed in BlockSparseArrays
function Base.AbstractUnitRange{T}(
a::AbstractGradedUnitRange{<:LabelledInteger{T}}
) where {T}
return unlabel_blocks(a)
end

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

Expand Down Expand Up @@ -249,8 +256,9 @@ function Base.getindex(a::AbstractGradedUnitRange, indices::BlockIndexRange)
return blockedunitrange_getindices(a, indices)
end

# fix ambiguity
function Base.getindex(
a::AbstractGradedUnitRange, indices::BlockRange{1,<:Tuple{AbstractUnitRange{Int}}}
a::AbstractGradedUnitRange, indices::BlockArrays.BlockRange{1,<:Tuple{Base.OneTo}}
)
return gradedunitrange_getindices(a, indices)
end
Expand Down

0 comments on commit 9796676

Please sign in to comment.