Skip to content

Commit

Permalink
fix getindex(a,::Vector{Int}
Browse files Browse the repository at this point in the history
  • Loading branch information
ogauthe committed Oct 31, 2024
1 parent a184141 commit db71962
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ end

function gradedunitrange_getindices(
a::AbstractGradedUnitRange,
indices::Union{AbstractVector{<:Block{1}},AbstractVector{<:BlockIndexRange{1}}},
indices::Union{
AbstractVector{<:Block{1}},AbstractVector{<:BlockIndexRange{1}},Vector{<:Integer}
},
)
return blockedunitrange_getindices(a, indices)
end
Expand Down
3 changes: 3 additions & 0 deletions NDTensors/src/lib/GradedAxes/test/test_basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ using Test: @test, @test_broken, @testset
@test eltype(a0) == Bool
@test length(a0) == 1
@test labelled_isequal(a0, a0)
@test a0[1] == true
@test a0[[1]] == [true]

@test labelled_isequal(a0, 1:1)
@test labelled_isequal(1:1, a0)
Expand Down Expand Up @@ -109,6 +111,7 @@ 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")]

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

0 comments on commit db71962

Please sign in to comment.