Skip to content

Commit

Permalink
improved some assertion messages
Browse files Browse the repository at this point in the history
as suggested by @fieker
  • Loading branch information
ThomasBreuer committed Jan 25, 2022
1 parent 7ee7566 commit 0644874
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Groups/libraries/perfectgroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ perfect groups in GAP's Perfect Groups Library.
The type `T` can be either `PermGroup` or `FPGroup`.
"""
function perfect_group(::Type{T}, n::Int, m::Int) where T <: GAPGroup
@assert m<= number_perfect_groups(n) "There are less than $m perfect groups of order $n, up to isomorphism."
N = number_perfect_groups(n)
@assert m <= N "There are only $N perfect groups of order $n, up to isomorphism."
if T==PermGroup
G = T(GAP.Globals.PerfectGroup(GAP.Globals.IsPermGroup,n,m))
elseif T==FPGroup
Expand Down
3 changes: 2 additions & 1 deletion src/Groups/libraries/primitivegroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Return the `i`-th group in the catalogue of primitive groups of degree `n`
in GAP's Primitive Groups Library. The output is a group of type `PermGroup`.
"""
function primitive_group(deg::Int, n::Int)
@assert n<= number_primitive_groups(deg) "There are less than $n primitive groups of degree $deg."
N = number_primitive_groups(deg)
@assert n <= N "There are only $N primitive groups of degree $deg."
return PermGroup(GAP.Globals.PrimitiveGroup(deg,n), deg)
end

Expand Down
3 changes: 2 additions & 1 deletion src/Groups/libraries/smallgroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ The group is given of type `PcGroup` if the group is solvable,
`PermGroup` otherwise.
"""
function small_group(n::Int, m::Int)
@assert m<= number_small_groups(n) "There are less than $m groups of order $n, up to isomorphism."
N = number_small_groups(n)
@assert m <= N "There are only $N groups of order $n, up to isomorphism."
G = GAP.Globals.SmallGroup(n, m)
T = _get_type(G)
return T(G)
Expand Down
3 changes: 2 additions & 1 deletion src/Groups/libraries/transitivegroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Return the `i`-th group in the catalogue of transitive groups over the set
The output is a group of type `PermGroup`.
"""
function transitive_group(deg::Int, n::Int)
@assert n<= number_transitive_groups(deg) "There are less than $n transitive groups of degree $deg, up to permutation isomorphism."
N = number_transitive_groups(deg)
@assert n <= N "There are only $N transitive groups of degree $deg, up to permutation isomorphism."

return PermGroup(GAP.Globals.TransitiveGroup(deg,n), deg)
end
Expand Down
10 changes: 10 additions & 0 deletions test/Groups/libraries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
@test issemiregular(H)
@test !isregular(H)
@test isregular(H,[1,2])

@test_throws AssertionError transitive_group(1, 2)
end

@testset "Perfect groups" begin
Expand All @@ -47,6 +49,8 @@ end
@test [number_perfect_groups(i) for i in 2:59]==[0 for i in 1:58]
x = perfect_identification(alternating_group(5))
@test isisomorphic(perfect_group(x[1],x[2]),alternating_group(5))[1]

@test_throws AssertionError perfect_group(60, 2)
end

@testset "Small groups" begin
Expand All @@ -62,4 +66,10 @@ end
@test length(all_small_groups(16, isabelian))==5
@test number_small_groups(16)==14
@test number_small_groups(17)==1

@test_throws AssertionError small_group(1, 2)
end

@testset "Primitive groups" begin
@test_throws AssertionError primitive_group(1, 1)
end

0 comments on commit 0644874

Please sign in to comment.