diff --git a/NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl b/NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl index 3a56cc49e7..287e4acd00 100644 --- a/NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl +++ b/NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl @@ -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) diff --git a/NDTensors/src/lib/GradedAxes/test/test_basics.jl b/NDTensors/src/lib/GradedAxes/test/test_basics.jl index 44e9ac083b..02d37f718f 100644 --- a/NDTensors/src/lib/GradedAxes/test/test_basics.jl +++ b/NDTensors/src/lib/GradedAxes/test/test_basics.jl @@ -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])