Skip to content

Commit

Permalink
Fix tests for primitive_by_shape and an_sn_by_shape (oscar-system#2573)
Browse files Browse the repository at this point in the history
If we sampled a bad set of elements, the tests could erroneously fail.
  • Loading branch information
fingolfin authored Jul 21, 2023
1 parent 5ff0130 commit c026a86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/NumberTheory/GaloisGrp/GaloisGrp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@ end


@doc raw"""
primitive_by_shape(ct::Set{CycleType}, n::Int)
primitive_by_shape(ct::Set{CycleType}, n::Int)
Return `true` if a transitive group $G \leq Sym(n)$ containing permutations
matching the cycle types in `ct` must be primitive, otherwise return `false`.
Expand Down
12 changes: 10 additions & 2 deletions test/NumberTheory/galthy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,23 @@ sample_cycle_structures(G::PermGroup) = Set(cycle_structure(rand_pseudo(G)) for
# note that we only check the implication, as there are cases in degree 15 and above
# where primitive_by_shape fails to detect primitivity
@testset "primitive_by_shape (randomized) in degree $n" for n in 12:length(grps)
@test all(G -> is_primitive(G) || !primitive_by_shape(sample_cycle_structures(G),n), grps[n] )
# If primitive_by_shape returns true then is_primitive must return true. If
# primitive_by_shape returns false then we can't say anything, as we just
# might have sampled bad elements.
# In other words, we test for the implication `primitive_by_shape => is_primitive`.
@test all(G -> !primitive_by_shape(sample_cycle_structures(G),n) || is_primitive(G), grps[n] )
end

@testset "an_sn_by_shape (exact) in degree $n" for n in 1:11
@test all(G -> naive_is_giant(G) == an_sn_by_shape(cycle_structures(G),n), grps[n] )
end

@testset "an_sn_by_shape (randomized) in degree $n" for n in 12:length(grps)
@test all(G -> naive_is_giant(G) == an_sn_by_shape(sample_cycle_structures(G),n), grps[n] )
# If an_sn_by_shape returns true then naive_is_giant must return true. If
# an_sn_by_shape returns false then we can't say anything, as we just
# might have sampled bad elements.
# In other words, we test for the implication `an_sn_by_shape => naive_is_giant`.
@test all(G -> !an_sn_by_shape(sample_cycle_structures(G),n) || naive_is_giant(G), grps[n] )
end

end

0 comments on commit c026a86

Please sign in to comment.