Skip to content

Commit db71962

Browse files
committed
fix getindex(a,::Vector{Int}
1 parent a184141 commit db71962

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ end
223223

224224
function gradedunitrange_getindices(
225225
a::AbstractGradedUnitRange,
226-
indices::Union{AbstractVector{<:Block{1}},AbstractVector{<:BlockIndexRange{1}}},
226+
indices::Union{
227+
AbstractVector{<:Block{1}},AbstractVector{<:BlockIndexRange{1}},Vector{<:Integer}
228+
},
227229
)
228230
return blockedunitrange_getindices(a, indices)
229231
end

NDTensors/src/lib/GradedAxes/test/test_basics.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ using Test: @test, @test_broken, @testset
2020
@test eltype(a0) == Bool
2121
@test length(a0) == 1
2222
@test labelled_isequal(a0, a0)
23+
@test a0[1] == true
24+
@test a0[[1]] == [true]
2325

2426
@test labelled_isequal(a0, 1:1)
2527
@test labelled_isequal(1:1, a0)
@@ -109,6 +111,7 @@ end
109111
@test blocklengths(ax) == blocklengths(a)
110112
@test blocklabels(ax) == blocklabels(a)
111113
@test blockfirsts(a) == [2, 3]
114+
@test x[[2, 4]] == [labelled(2, "x"), labelled(4, "y")]
112115

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

0 commit comments

Comments
 (0)