From 576371fb8490b6a213af959c9931e26cbe5a1470 Mon Sep 17 00:00:00 2001 From: Erik Paemurru <143521159+paemurru@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:48:18 +0100 Subject: [PATCH] getindex(x::FinGenAbGroupElem, ::Colon) (#1720) --- src/GrpAb/Elem.jl | 4 ++++ test/GrpAb/Elem.jl | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/GrpAb/Elem.jl b/src/GrpAb/Elem.jl index 06103a753e..e93914db7b 100644 --- a/src/GrpAb/Elem.jl +++ b/src/GrpAb/Elem.jl @@ -138,6 +138,10 @@ function Base.lastindex(x::FinGenAbGroupElem) return ngens(parent(x)) end +function getindex(x::FinGenAbGroupElem, ::Colon) + return x[begin:end] +end + ################################################################################ # # Comparison diff --git a/test/GrpAb/Elem.jl b/test/GrpAb/Elem.jl index 04dd9bf9ec..fb9340405b 100644 --- a/test/GrpAb/Elem.jl +++ b/test/GrpAb/Elem.jl @@ -7,6 +7,7 @@ @test parent(a) == G @test a.coeff == N @test a[begin:end] == [0, 0, 0] + @test a[:] == [0, 0, 0] G = @inferred abelian_group([3, 0]) N = ZZ[1 1] @@ -14,6 +15,7 @@ @test @inferred parent(a) == G @test a.coeff == N @test a[begin:end] == [1, 1] + @test a[:] == [1, 1] N = matrix(ZZ, 1, 2, [ 1, 1 ]) a = @inferred G(N) @@ -24,6 +26,7 @@ @test @inferred parent(a) == G @test a.coeff == transpose(N) @test a[begin:end] == [1, 1] + @test a[:] == [1, 1] end @testset "Generators" begin