music.InterestingPermutations

class music.InterestingPermutations(nelements=4, method='dimino')[source]

Bases: object

Get permutations of n elements in meaningful sequences. Mirrors are ordered by swaps (0,n-1…).

Methods

get_alternating()

Generates permutations in the alternating group.

get_rotations()

Generates rotations of permutations.

get_mirrors()

Generates mirror permutations.

get_swaps()

Generates swap permutations.

even_odd(sequence)

Determines if a permutation is even or odd.

get_full_symmetry()

Generates permutations with full symmetry.

__init__(nelements=4, method='dimino')[source]

Methods

__init__([nelements, method])

even_odd(sequence)

Determines if a permutation is even or odd.

get_alternating()

Generates permutations in the alternating group.

get_full_symmetry()

Generates permutations with full symmetry.

get_mirrors()

Generates mirror permutations.

get_rotations()

Generates rotations of permutations.

get_swaps()

Generates swap permutations.

Attributes

permutations_by_sizes: list
permutations: list
neighbor_swaps: list
swaps_by_stepsizes: list
swaps_as_comes: list
swaps: list
rotations: list
mirrors: list
dihedral: list
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.

even_odd(sequence)[source]

Determines if a permutation is even or odd.

This method determines if a given permutation is even or odd based on its sequence of elements.

Parameters:
sequencelist

The sequence of elements representing the permutation.

Returns:
str

Either ‘even’ or ‘odd’ indicating the parity of the permutation.

get_full_symmetry()[source]

Generates permutations with full symmetry.

This method generates permutations with full symmetry of the specified size using the provided generation method.