# Test Utilities¶

diofant.combinatorics.testutil._cmp_perm_lists(first, second)[source]

Compare two lists of permutations as sets.

This is used for testing purposes. Since the array form of a permutation is currently a list, Permutation is not hashable and cannot be put into a set.

Examples

>>> a = Permutation([0, 2, 3, 4, 1])
>>> b = Permutation([1, 2, 0, 4, 3])
>>> c = Permutation([3, 4, 0, 1, 2])
>>> ls1 = [a, b, c]
>>> ls2 = [b, c, a]
>>> _cmp_perm_lists(ls1, ls2)
True

diofant.combinatorics.testutil._naive_list_centralizer(self, other, af=False)[source]
diofant.combinatorics.testutil._verify_bsgs(group, base, gens)[source]

Verify the correctness of a base and strong generating set.

This is a naive implementation using the definition of a base and a strong generating set relative to it. There are other procedures for verifying a base and strong generating set, but this one will serve for more robust testing.

Examples

>>> A = AlternatingGroup(4)
>>> A.schreier_sims()
>>> _verify_bsgs(A, A.base, A.strong_gens)
True

diofant.combinatorics.testutil._verify_centralizer(group, arg, centr=None)[source]

Verify the centralizer of a group/set/element inside another group.

This is used for testing .centralizer() from diofant.combinatorics.perm_groups

Examples

… AlternatingGroup) >>> S = SymmetricGroup(5) >>> A = AlternatingGroup(5) >>> centr = PermutationGroup([Permutation([0, 1, 2, 3, 4])]) >>> _verify_centralizer(S, A, centr) True

diofant.combinatorics.testutil._verify_normal_closure(group, arg, closure=None)[source]

Verify the normal closure of a subgroup/subset/element in a group.

This is used to test diofant.combinatorics.perm_groups.PermutationGroup.normal_closure

Examples

>>> S = SymmetricGroup(3)
>>> A = AlternatingGroup(3)
>>> _verify_normal_closure(S, A, closure=A)
True