music.GenericPeal¶
- class music.GenericPeal[source]¶
Bases:
objectA collection of named peals that can be acted on a domain.
The base for the named-peal model: peals maps a name to a list of permutations, and act applies one of them by name.
Pealsworks that way and inherits this.music.PlainChangesdeliberately does not. It is built from one peal rather than holding several, so its act acts that peal and takes the domain first –act(domain)rather thanact(name, domain). The two are different operations that happen to share a verb.- Attributes:
Methods
act(peal[, domain])Acts a specific peal on the specified domain.
act_all([domain])Acts all peals on the specified domain.
Examples
>>> peal = GenericPeal() >>> peal.peals = {"rows": PlainChanges(4).peal_direct[:4]} >>> rows = peal.act("rows", domain=[220, 275, 330, 440]) >>> len(rows), len(rows[0]) (4, 4)
nelements is what a default domain would be built from, so a bare GenericPeal needs the domain passed:
>>> peal.act("rows") Traceback (most recent call last): ... ValueError: nelements has not been set, ...
Methods
__init__()Initializes a GenericPeal object.
act(peal[, domain])Acts a specific peal on the specified domain.
act_all([domain])Acts all peals on the specified domain.
Attributes
name -> list of permutations.
- peals: dict¶
name -> list of permutations. Empty rather than None: a collection with nothing in it is what an unpopulated one is, and act() refuses to run on either.
- act(peal, domain=None)[source]¶
Acts a specific peal on the specified domain.
- Parameters:
- Returns:
listThe result of acting the peal on the specified domain.
- Raises:
ValueErrorIf no peals are defined, no domain is given and nelements is not set, or the domain’s length is not the number of elements the peal permutes.
KeyErrorIf no peal goes by peal.
- act_all(domain=None)[source]¶
Acts all peals on the specified domain.
- Parameters:
- domain
list,optional The domain on which to act the peals. Defaults to None.
- domain
- Raises:
ValueErrorAs
act()raises it.