music.InterestingPermutations¶
- class music.InterestingPermutations(nelements=4, method='dimino')[source]¶
Bases:
objectGet permutations of n elements in meaningful sequences. Mirrors are ordered by swaps (0,n-1…).
- Parameters:
- nelements
integer How many elements are permuted. Every group generated here – symmetric, alternating, cyclic, dihedral – is the group on this many elements, so it also sets how many permutations there are.
- method
str The generation method handed to sympy’s group
generate(), such as"dimino"or"coset". It changes the order the permutations come out in, which is the sequence this class exists to make meaningful, and not which permutations they are.
- nelements
Methods
Generates permutations in the alternating group.
Generates rotations of permutations.
Generates mirror permutations.
Generates swap permutations.
even_odd(sequence)Determines if a permutation is even or odd.
Generates permutations with full symmetry.
Examples
>>> structures = InterestingPermutations(nelements=4) >>> len(structures.rotations), len(structures.dihedral) (4, 8) >>> rows = [p(list("abcd")) for p in structures.rotations] >>> ["".join(row) for row in rows] ['abcd', 'bcda', 'cdab', 'dabc']
Methods
__init__([nelements, method])even_odd(sequence)Determines if a permutation is even or odd.
Generates permutations in the alternating group.
Generates permutations with full symmetry.
Generates mirror permutations.
Generates rotations of permutations.
Generates swap permutations.
Attributes
- get_alternating()[source]¶
Generates permutations in the alternating group.
This method generates permutations in the alternating group of the specified size using the provided generation method.
- get_rotations()[source]¶
Generates rotations of permutations.
This method generates rotations of permutations of the specified size using the provided generation method.
- get_mirrors()[source]¶
Generates mirror permutations.
This method generates mirror permutations of the specified size using the provided generation method.
- get_swaps()[source]¶
Generates swap permutations.
This method generates swap permutations of the specified size using the provided generation method.