PartAssignment

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.segments" { graph [label="abjad.segments"]; node [color=1]; "abjad.segments.PartAssignment.PartAssignment" [URL="../api/abjad/segments/PartAssignment.html#abjad.segments.PartAssignment.PartAssignment", color=black, fontcolor=white, label="Part\nAssignment", target=_top]; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/segments/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.AbjadValueObject.AbjadValueObject" [URL="../api/abjad/segments/../system/AbjadValueObject.html#abjad.system.AbjadValueObject.AbjadValueObject", label="Abjad\nValue\nObject", target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.AbjadValueObject.AbjadValueObject"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.segments.PartAssignment.PartAssignment"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.segments.PartAssignment.PartAssignment(section=None, token=None)

Part assignment.

>>> abjad.PartAssignment('Horn')
PartAssignment('Horn')
>>> abjad.PartAssignment('Horn', 1)
PartAssignment('Horn', 1)
>>> abjad.PartAssignment('Horn', 2)
PartAssignment('Horn', 2)
>>> abjad.PartAssignment('Horn', (3, 4))
PartAssignment('Horn', (3, 4))
>>> abjad.PartAssignment('Horn', [1, 3])
PartAssignment('Horn', [1, 3])
>>> part_assignment = abjad.PartAssignment('Horn', [1, 3])
>>> abjad.f(part_assignment)
PartAssignment('Horn', [1, 3])
>>> print(format(part_assignment))
abjad.PartAssignment('Horn', [1, 3])

Attributes Summary

__contains__ Is true when part assignment contains part.
__eq__ Is true when argument is a part assignment with section and members equal to this part assignment.
__hash__ Hashes part assignment.
__iter__ Iterates parts in assignment.
members Gets members.
parts Gets parts.
section Gets section.
token Gets token.
token_type

Special methods

__contains__(part)

Is true when part assignment contains part.

>>> parts = [
...     abjad.Part(section='Horn', member= 1),
...     abjad.Part(section='Horn', member= 2),
...     abjad.Part(section='Horn', member= 3),
...     abjad.Part(section='Horn', member= 4),
...     ]
>>> part_assignment = abjad.PartAssignment('Horn')
>>> for part in parts:
...     part, part in part_assignment
...
(Part(instrument='Horn', member=1, section='Horn'), True)
(Part(instrument='Horn', member=2, section='Horn'), True)
(Part(instrument='Horn', member=3, section='Horn'), True)
(Part(instrument='Horn', member=4, section='Horn'), True)
>>> part_assignment = abjad.PartAssignment('Horn', 1)
>>> for part in parts:
...     part, part in part_assignment
...
(Part(instrument='Horn', member=1, section='Horn'), True)
(Part(instrument='Horn', member=2, section='Horn'), False)
(Part(instrument='Horn', member=3, section='Horn'), False)
(Part(instrument='Horn', member=4, section='Horn'), False)
>>> part_assignment = abjad.PartAssignment('Horn', 2)
>>> for part in parts:
...     part, part in part_assignment
...
(Part(instrument='Horn', member=1, section='Horn'), False)
(Part(instrument='Horn', member=2, section='Horn'), True)
(Part(instrument='Horn', member=3, section='Horn'), False)
(Part(instrument='Horn', member=4, section='Horn'), False)
>>> part_assignment = abjad.PartAssignment('Horn', (3, 4))
>>> for part in parts:
...     part, part in part_assignment
...
(Part(instrument='Horn', member=1, section='Horn'), False)
(Part(instrument='Horn', member=2, section='Horn'), False)
(Part(instrument='Horn', member=3, section='Horn'), True)
(Part(instrument='Horn', member=4, section='Horn'), True)
>>> part_assignment = abjad.PartAssignment('Horn', [1, 3])
>>> for part in parts:
...     part, part in part_assignment
...
(Part(instrument='Horn', member=1, section='Horn'), True)
(Part(instrument='Horn', member=2, section='Horn'), False)
(Part(instrument='Horn', member=3, section='Horn'), True)
(Part(instrument='Horn', member=4, section='Horn'), False)

Raises exception when input is not part:

>>> part_assignment = abjad.PartAssignment('Horn')
>>> 'Horn' in part_assignment
Traceback (most recent call last):
    ...
TypeError: must be part (not 'Horn').
Return type:bool
(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

__eq__(argument)

Is true when argument is a part assignment with section and members equal to this part assignment.

>>> part_assignment_1 = abjad.PartAssignment('Horn', (1, 2))
>>> part_assignment_2 = abjad.PartAssignment('Horn', [1, 2])
>>> part_assignment_3 = abjad.PartAssignment('Horn')
>>> part_assignment_1 == part_assignment_1
True
>>> part_assignment_1 == part_assignment_2
True
>>> part_assignment_1 == part_assignment_3
False
>>> part_assignment_2 == part_assignment_1
True
>>> part_assignment_2 == part_assignment_2
True
>>> part_assignment_2 == part_assignment_3
False
>>> part_assignment_3 == part_assignment_1
False
>>> part_assignment_3 == part_assignment_2
False
>>> part_assignment_3 == part_assignment_3
True
Return type:bool
(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

__hash__()

Hashes part assignment.

Return type:int
__iter__()

Iterates parts in assignment.

>>> part_assignment = abjad.PartAssignment('Horn', [1, 3])
>>> for part in part_assignment:
...     part
...
Part(instrument='Horn', member=1, section='Horn')
Part(instrument='Horn', member=3, section='Horn')
(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Read-only properties

members

Gets members.

>>> abjad.PartAssignment('Horn').members is None
True
>>> abjad.PartAssignment('Horn', 1).members
[1]
>>> abjad.PartAssignment('Horn', 2).members
[2]
>>> abjad.PartAssignment('Horn', (3, 4)).members
[3, 4]
>>> abjad.PartAssignment('Horn', [1, 3]).members
[1, 3]
Return type:Optional[List[int]]
parts

Gets parts.

>>> abjad.PartAssignment('Horn').parts
[Part(instrument='Horn', section='Horn')]
>>> abjad.PartAssignment('Horn', 1).parts
[Part(instrument='Horn', member=1, section='Horn')]
>>> abjad.PartAssignment('Horn', 2).parts
[Part(instrument='Horn', member=2, section='Horn')]
>>> abjad.PartAssignment('Horn', (3, 4)).parts
[Part(instrument='Horn', member=3, section='Horn'), Part(instrument='Horn', member=4, section='Horn')]
>>> abjad.PartAssignment('Horn', [1, 3]).parts
[Part(instrument='Horn', member=1, section='Horn'), Part(instrument='Horn', member=3, section='Horn')]
Return type:List[Part]
section

Gets section.

>>> abjad.PartAssignment('Horn').section
'Horn'
>>> abjad.PartAssignment('Horn', 1).section
'Horn'
>>> abjad.PartAssignment('Horn', 2).section
'Horn'
>>> abjad.PartAssignment('Horn', (3, 4)).section
'Horn'
>>> abjad.PartAssignment('Horn', [1, 3]).section
'Horn'
Return type:Optional[str]
token

Gets token.

>>> abjad.PartAssignment('Horn').token is None
True
>>> abjad.PartAssignment('Horn', 1).token
1
>>> abjad.PartAssignment('Horn', 2).token
2
>>> abjad.PartAssignment('Horn', (3, 4)).token
(3, 4)
>>> abjad.PartAssignment('Horn', [1, 3]).token
[1, 3]
Return type:Union[None, int, Tuple[int, int], List[int]]