Skip to content

Commit

Permalink
fix ambiguities
Browse files Browse the repository at this point in the history
  • Loading branch information
ogauthe committed Nov 1, 2024
1 parent 9796676 commit 3b8b2b9
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl
Original file line number Diff line number Diff line change
@@ -256,12 +256,17 @@ function Base.getindex(a::AbstractGradedUnitRange, indices::BlockIndexRange)
return blockedunitrange_getindices(a, indices)
end

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

function Base.getindex(a::AbstractGradedUnitRange, indices::BlockIndex{1})
return gradedunitrange_getindices(a, indices)
3 changes: 3 additions & 0 deletions NDTensors/src/lib/GradedAxes/test/test_basics.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@eval module $(gensym())
using BlockArrays:
Block,
BlockRange,
BlockSlice,
BlockVector,
blockedrange,
@@ -111,7 +112,9 @@ end
@test blocklengths(ax) == blocklengths(a)
@test blocklabels(ax) == blocklabels(a)
@test blockfirsts(a) == [2, 3]

@test x[[2, 4]] == [labelled(2, "x"), labelled(4, "y")]
@test labelled_isequal(x[BlockRange(1)], gradedrange(["x" => 2]))

# Regression test for ambiguity error.
x = gradedrange(["x" => 2, "y" => 3])

0 comments on commit 3b8b2b9

Please sign in to comment.