From db719624a335739928f6ce1d06a0393c6b5416c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Gauth=C3=A9?= Date: Thu, 31 Oct 2024 19:05:41 -0400 Subject: [PATCH] fix getindex(a,::Vector{Int} --- NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl | 4 +++- NDTensors/src/lib/GradedAxes/test/test_basics.jl | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl b/NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl index 60e067699f..7738d975a9 100644 --- a/NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl +++ b/NDTensors/src/lib/GradedAxes/src/gradedunitrange.jl @@ -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 diff --git a/NDTensors/src/lib/GradedAxes/test/test_basics.jl b/NDTensors/src/lib/GradedAxes/test/test_basics.jl index 43dc53302d..44e9ac083b 100644 --- a/NDTensors/src/lib/GradedAxes/test/test_basics.jl +++ b/NDTensors/src/lib/GradedAxes/test/test_basics.jl @@ -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) @@ -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])