Skip to content

Commit

Permalink
getindex(x::FinGenAbGroupElem, ::Colon) (#1720)
Browse files Browse the repository at this point in the history
  • Loading branch information
paemurru authored Jan 9, 2025
1 parent e16ff76 commit 576371f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/GrpAb/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/GrpAb/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
@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]
a = @inferred FinGenAbGroupElem(G, N)
@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)
Expand All @@ -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
Expand Down

0 comments on commit 576371f

Please sign in to comment.