parentage

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.parentage" { graph [label="abjad.parentage"]; node [color=1]; "abjad.parentage.Parentage" [URL="../api/abjad/parentage.html#abjad.parentage.Parentage", color=black, fontcolor=white, label=Parentage, target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3.10/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_collections.abc" { graph [label="collections.abc"]; node [color=3]; "collections.abc.Collection" [URL="https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Collection", label=Collection, shape=oval, style=bold, target=_top]; "collections.abc.Container" [URL="https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Container", label=Container, shape=oval, style=bold, target=_top]; "collections.abc.Iterable" [URL="https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Iterable", label=Iterable, shape=oval, style=bold, target=_top]; "collections.abc.Reversible" [URL="https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Reversible", label=Reversible, shape=oval, style=bold, target=_top]; "collections.abc.Sequence" [URL="https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sequence", label=Sequence, shape=oval, style=bold, target=_top]; "collections.abc.Sized" [URL="https://docs.python.org/3.10/library/collections.abc.html#collections.abc.Sized", label=Sized, shape=oval, style=bold, target=_top]; "collections.abc.Collection" -> "collections.abc.Sequence"; "collections.abc.Container" -> "collections.abc.Collection"; "collections.abc.Iterable" -> "collections.abc.Collection"; "collections.abc.Iterable" -> "collections.abc.Reversible"; "collections.abc.Reversible" -> "collections.abc.Sequence"; "collections.abc.Sized" -> "collections.abc.Collection"; } "builtins.object" -> "collections.abc.Container"; "builtins.object" -> "collections.abc.Iterable"; "builtins.object" -> "collections.abc.Sized"; "collections.abc.Sequence" -> "abjad.parentage.Parentage"; }


Classes

Parentage

Parentage of a component.

class abjad.parentage.Parentage(component=None)[source]

Parentage of a component.

>>> score = abjad.Score()
>>> string = r"""\new Voice = "Treble_Voice" { e'4 }"""
>>> treble_staff = abjad.Staff(string, name="Treble_Staff")
>>> score.append(treble_staff)
>>> string = r"""\new Voice = "Bass_Voice" { c4 }"""
>>> bass_staff = abjad.Staff(string, name="Bass_Staff")
>>> clef = abjad.Clef("bass")
>>> abjad.attach(clef, bass_staff[0][0])
>>> score.append(bass_staff)
>>> abjad.show(score)  
>>> bass_voice = score["Bass_Voice"]
>>> note = bass_voice[0]
>>> for component in abjad.get.parentage(note):
...     component
... 
Note('c4')
Voice('c4', name='Bass_Voice')
Staff('{ c4 }', name='Bass_Staff')
Score("{ { e'4 } } { { c4 } }", simultaneous=True)

Attributes Summary

__eq__

Is true when argument is a parent with the same components as this parentage.

__getitem__

Gets argument.

__len__

Gets number of components in parentage.

__repr__

Gets repr.

component

Gets component.

components

Gets components.

count

Gets number of prototype in parentage.

get

Gets instance n of prototype in parentage.

logical_voice

Gets logical voice.

orphan

Is true when component has no parent.

parent

Gets parent.

prolation

Gets prolation.

root

Gets root.

score_index

Gets score index.


Special methods

classmethod (Iterable).__class_getitem__()

Represent a PEP 585 generic type

E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).

(Sequence).__contains__(value)
overridden __eq__(argument)[source]

Is true when argument is a parent with the same components as this parentage.

overridden __getitem__(argument)[source]

Gets argument.

Returns component or tuple of components.

(Sequence).__iter__()
overridden __len__()[source]

Gets number of components in parentage.

Return type:

int

overridden __repr__()[source]

Gets repr.

(Sequence).__reversed__()

Methods

overridden count(prototype=None)[source]

Gets number of prototype in parentage.

Gets tuplet count:

>>> staff = abjad.Staff(
...     r"\times 2/3 { c'2 \times 2/3 { d'8 e' f' } } \times 2/3 { c'4 d' e' }"
... )
>>> abjad.show(staff)  
>>> for component in abjad.select.components(staff):
...     parentage = abjad.get.parentage(component)
...     count = parentage.count(abjad.Tuplet)
...     print(f"{repr(component):55} {repr(count)}")
... 
Staff("{ 2/3 c'2 { 2/3 d'8 e'8 f'8 } } { 2/3 c'4 d'4 e'4 }") 0
Tuplet('3:2', "c'2 { 2/3 d'8 e'8 f'8 }")                1
Note("c'2")                                             1
Tuplet('3:2', "d'8 e'8 f'8")                            2
Note("d'8")                                             2
Note("e'8")                                             2
Note("f'8")                                             2
Tuplet('3:2', "c'4 d'4 e'4")                            1
Note("c'4")                                             1
Note("d'4")                                             1
Note("e'4")                                             1

Gets voice count:

>>> outer_red_voice = abjad.Voice("e''8 d''", name="Red_Voice")
>>> inner_red_voice = abjad.Voice("c''4 b' c''8", name="Red_Voice")
>>> inner_blue_voice = abjad.Voice("e'4 f' e'8", name="Blue_Voice")
>>> container = abjad.Container(
...     [inner_red_voice, inner_blue_voice],
...     simultaneous=True,
... )
>>> outer_red_voice.append(container)
>>> outer_red_voice.extend("d''8")
>>> abjad.override(outer_red_voice).NoteHead.color = "#red"
>>> command = abjad.VoiceNumber(1)
>>> abjad.attach(command, outer_red_voice[0])
>>> abjad.override(inner_blue_voice).NoteHead.color = "#blue"
>>> command = abjad.VoiceNumber(2)
>>> abjad.attach(command, inner_blue_voice[0])
>>> dynamic = abjad.Dynamic("f")
>>> abjad.attach(dynamic, outer_red_voice[0])
>>> abjad.show(outer_red_voice)  
>>> for leaf in abjad.iterate.leaves(outer_red_voice):
...     depth = abjad.get.parentage(leaf).count(abjad.Voice)
...     print(leaf, depth)
... 
Note("e''8") 1
Note("d''8") 1
Note("c''4") 2
Note("b'4") 2
Note("c''8") 2
Note("e'4") 2
Note("f'4") 2
Note("e'8") 2
Note("d''8") 1

REGRESSION. Works with grace notes (and containers):

>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice")
>>> container = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container, music_voice[1])
>>> container = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[2:3])
>>> abjad.attach(abjad.Articulation(">"), container[0])
>>> container = abjad.AfterGraceContainer("fs'16")
>>> abjad.attach(container, music_voice[3])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  
>>> for component in abjad.select.components(staff):
...     parentage = abjad.get.parentage(component)
...     count = parentage.count(abjad.Staff)
...     print(f"{repr(component):30} {repr(count)}")
... 
Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }") 1
Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice') 1
Note("c'4")                    1
BeforeGraceContainer("cs'16")  1
Note("cs'16")                  1
Note("d'4")                    1
Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }") 1
OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16") 1
Chord("<e' g'>16")             1
Note("gs'16")                  1
Note("a'16")                   1
Note("as'16")                  1
Voice("e'4", name='MusicVoice') 1
Note("e'4")                    1
Note("f'4")                    1
AfterGraceContainer("fs'16")   1
Note("fs'16")                  1
Return type:

int

get(prototype=None, n=0)[source]

Gets instance n of prototype in parentage.

>>> outer_red_voice = abjad.Voice("e''8 d''", name="Red_Voice")
>>> inner_red_voice = abjad.Voice("c''4 b' c''8", name="Red_Voice")
>>> inner_blue_voice = abjad.Voice("e'4 f' e'8", name="Blue_Voice")
>>> container = abjad.Container(
...     [inner_red_voice, inner_blue_voice],
...     simultaneous=True,
... )
>>> outer_red_voice.append(container)
>>> outer_red_voice.extend("d''8")
>>> abjad.override(outer_red_voice).NoteHead.color = "#red"
>>> command = abjad.VoiceNumber(1)
>>> abjad.attach(command, outer_red_voice[0])
>>> abjad.override(inner_blue_voice).NoteHead.color = "#blue"
>>> command = abjad.VoiceNumber(2)
>>> abjad.attach(command, inner_blue_voice[0])
>>> dynamic = abjad.Dynamic("f")
>>> abjad.attach(dynamic, outer_red_voice[0])
>>> abjad.show(outer_red_voice)  
>>> leaf = abjad.get.leaf(inner_red_voice, 0)
>>> leaf
Note("c''4")
>>> parentage = abjad.get.parentage(leaf)

Returns self when n=0:

>>> parentage.get(abjad.Component, 0)
Note("c''4")

Returns parents with positive n:

>>> parentage.get(abjad.Component, 1)
Voice("c''4 b'4 c''8", name='Red_Voice')
>>> parentage.get(abjad.Component, 2)
Container("{ c''4 b'4 c''8 } { e'4 f'4 e'8 }")
>>> parentage.get(abjad.Component, 3)
Voice("e''8 d''8 { { c''4 b'4 c''8 } { e'4 f'4 e'8 } } d''8", name='Red_Voice')

Returns none with n greater than score depth:

>>> parentage.get(abjad.Component, 4) is None
True
>>> parentage.get(abjad.Component, 5) is None
True
>>> parentage.get(abjad.Component, 99) is None
True

Returns score root with n=-1:

>>> parentage.get(abjad.Component, -1)
Voice("e''8 d''8 { { c''4 b'4 c''8 } { e'4 f'4 e'8 } } d''8", name='Red_Voice')

With other negative n:

>>> parentage.get(abjad.Component, -2)
Container("{ c''4 b'4 c''8 } { e'4 f'4 e'8 }")
>>> parentage.get(abjad.Component, -3)
Voice("c''4 b'4 c''8", name='Red_Voice')
>>> parentage.get(abjad.Component, -4)
Note("c''4")

Returns none for sufficiently negative n:

>>> parentage.get(abjad.Component, -5) is None
True
>>> parentage.get(abjad.Component, -7) is None
True
>>> parentage.get(abjad.Component, -99) is None
True

Works with nested voices and tuplets:

>>> leaf = abjad.get.leaf(inner_red_voice, 0)
>>> parentage = abjad.get.parentage(leaf)
>>> leaf
Note("c''4")

Nonnegative n:

>>> parentage.get(abjad.Voice, 0)
Voice("c''4 b'4 c''8", name='Red_Voice')
>>> parentage.get(abjad.Voice, 1)
Voice("e''8 d''8 { { c''4 b'4 c''8 } { e'4 f'4 e'8 } } d''8", name='Red_Voice')
>>> parentage.get(abjad.Voice, 2) is None
True
>>> parentage.get(abjad.Voice, 9) is None
True

Negative n:

>>> parentage.get(abjad.Voice, -1)
Voice("e''8 d''8 { { c''4 b'4 c''8 } { e'4 f'4 e'8 } } d''8", name='Red_Voice')
>>> parentage.get(abjad.Voice, -2)
Voice("c''4 b'4 c''8", name='Red_Voice')
>>> parentage.get(abjad.Voice, -3) is None
True
>>> parentage.get(abjad.Voice, -99) is None
True

REGRESSION. Works with grace notes (and containers):

>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice")
>>> container = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container, music_voice[1])
>>> container = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[2:3])
>>> abjad.attach(abjad.Articulation(">"), container[0])
>>> container = abjad.AfterGraceContainer("fs'16")
>>> abjad.attach(container, music_voice[3])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  
>>> for component in abjad.select.components(staff):
...     parentage = abjad.get.parentage(component)
...     result = parentage.get(abjad.Staff)
...     print(f"{repr(component):30} {repr(result)}")
... 
Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }") Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice') Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("c'4")                    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
BeforeGraceContainer("cs'16")  Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("cs'16")                  Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("d'4")                    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }") Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16") Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Chord("<e' g'>16")             Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("gs'16")                  Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("a'16")                   Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("as'16")                  Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Voice("e'4", name='MusicVoice') Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("e'4")                    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("f'4")                    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
AfterGraceContainer("fs'16")   Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("fs'16")                  Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Return type:

Optional[Component]

(Sequence).index(value[, start[, stop]]) integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

logical_voice()[source]

Gets logical voice.

Gets logical voice of note:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4", name="MusicVoice")
>>> staff = abjad.Staff([voice], name="Music_Staff")
>>> score = abjad.Score([staff], name="Score")
>>> abjad.show(score)  
>>> note = voice[0]
>>> parentage = abjad.get.parentage(note)
>>> parentage.logical_voice()
{'score': "Score-'Score'", 'staff group': '', 'staff': "Staff-'Music_Staff'", 'voice': "Voice-'MusicVoice'"}

REGRESSION. Works with grace notes (and containers):

>>> voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice")
>>> container_1 = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container_1, voice[1])
>>> container_2 = abjad.AfterGraceContainer("fs'16")
>>> abjad.attach(container_2, voice[3])
>>> abjad.show(voice)  
>>> abjad.get.parentage(voice).logical_voice()
{'score': '', 'staff group': '', 'staff': '', 'voice': "Voice-'MusicVoice'"}
>>> abjad.get.parentage(container_1).logical_voice()
{'score': '', 'staff group': '', 'staff': '', 'voice': "Voice-'MusicVoice'"}
>>> abjad.get.parentage(container_1[0]).logical_voice()
{'score': '', 'staff group': '', 'staff': '', 'voice': "Voice-'MusicVoice'"}
>>> abjad.get.parentage(container_2).logical_voice()
{'score': '', 'staff group': '', 'staff': '', 'voice': "Voice-'MusicVoice'"}
>>> abjad.get.parentage(container_2[0]).logical_voice()
{'score': '', 'staff group': '', 'staff': '', 'voice': "Voice-'MusicVoice'"}
Return type:

dict

score_index()[source]

Gets score index.

>>> staff_1 = abjad.Staff(r"\times 2/3 { c''2 b'2 a'2 }")
>>> staff_2 = abjad.Staff("c'2 d'2")
>>> score = abjad.Score([staff_1, staff_2])
>>> abjad.show(score)  
>>> for component in abjad.select.components(score):
...     parentage = abjad.get.parentage(component)
...     component, parentage.score_index()
... 
(Score("{ { 2/3 c''2 b'2 a'2 } } { c'2 d'2 }", simultaneous=True), ())
(Staff("{ 2/3 c''2 b'2 a'2 }"), (0,))
(Tuplet('3:2', "c''2 b'2 a'2"), (0, 0))
(Note("c''2"), (0, 0, 0))
(Note("b'2"), (0, 0, 1))
(Note("a'2"), (0, 0, 2))
(Staff("c'2 d'2"), (1,))
(Note("c'2"), (1, 0))
(Note("d'2"), (1, 1))

Score root sets score index to ().

REGRESSION. Works with grace notes (and containers):

>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice")
>>> container = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container, music_voice[1])
>>> container = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[2:3])
>>> abjad.attach(abjad.Articulation(">"), container[0])
>>> container = abjad.AfterGraceContainer("fs'16")
>>> abjad.attach(container, music_voice[3])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  
>>> for component in abjad.select.components(staff):
...     parentage = abjad.get.parentage(component)
...     score_index = parentage.score_index()
...     print(f"{repr(component):30} {repr(score_index)}")
... 
Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }") ()
Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice') (0,)
Note("c'4")                    (0, 0)
BeforeGraceContainer("cs'16")  (0, 0, 1, '-G')
Note("cs'16")                  (0, 0, 1, '-G', 0)
Note("d'4")                    (0, 1)
Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }") (0, 2)
OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16") (0, 2, 0)
Chord("<e' g'>16")             (0, 2, 0, 0)
Note("gs'16")                  (0, 2, 0, 1)
Note("a'16")                   (0, 2, 0, 2)
Note("as'16")                  (0, 2, 0, 3)
Voice("e'4", name='MusicVoice') (0, 2, 1)
Note("e'4")                    (0, 2, 1, 0)
Note("f'4")                    (0, 3)
AfterGraceContainer("fs'16")   (0, 0, 3, '+G')
Note("fs'16")                  (0, 0, 3, '+G', 0)
Return type:

tuple[int | str, ...]


Read-only properties

component

Gets component.

REGRESSION. Works with grace notes (and containers):

>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice")
>>> container = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container, music_voice[1])
>>> container = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[2:3])
>>> abjad.attach(abjad.Articulation(">"), container[0])
>>> container = abjad.AfterGraceContainer("fs'16")
>>> abjad.attach(container, music_voice[3])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  
>>> for component in abjad.select.components(staff):
...     parentage = abjad.get.parentage(component)
...     print(f"{repr(component):30} {repr(parentage.component)}")
... 
Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }") Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice') Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
Note("c'4")                    Note("c'4")
BeforeGraceContainer("cs'16")  BeforeGraceContainer("cs'16")
Note("cs'16")                  Note("cs'16")
Note("d'4")                    Note("d'4")
Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }") Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }")
OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16") OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16")
Chord("<e' g'>16")             Chord("<e' g'>16")
Note("gs'16")                  Note("gs'16")
Note("a'16")                   Note("a'16")
Note("as'16")                  Note("as'16")
Voice("e'4", name='MusicVoice') Voice("e'4", name='MusicVoice')
Note("e'4")                    Note("e'4")
Note("f'4")                    Note("f'4")
AfterGraceContainer("fs'16")   AfterGraceContainer("fs'16")
Note("fs'16")                  Note("fs'16")
components

Gets components.

REGRESSION. Works with grace notes (and containers):

>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice")
>>> container = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container, music_voice[1])
>>> container = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[2:3])
>>> abjad.attach(abjad.Articulation(">"), container[0])
>>> container = abjad.AfterGraceContainer("fs'16")
>>> abjad.attach(container, music_voice[3])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  
>>> for component in abjad.select.components(staff):
...     parentage = abjad.get.parentage(component)
...     components = parentage.components
...     print(f"{repr(component)}:")
...     for component_ in components:
...         print(f"    {repr(component_)}")
... 
Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }"):
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice'):
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("c'4"):
    Note("c'4")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
BeforeGraceContainer("cs'16"):
    BeforeGraceContainer("cs'16")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("cs'16"):
    Note("cs'16")
    BeforeGraceContainer("cs'16")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("d'4"):
    Note("d'4")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }"):
    Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16"):
    OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16")
    Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Chord("<e' g'>16"):
    Chord("<e' g'>16")
    OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16")
    Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("gs'16"):
    Note("gs'16")
    OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16")
    Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("a'16"):
    Note("a'16")
    OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16")
    Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("as'16"):
    Note("as'16")
    OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16")
    Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Voice("e'4", name='MusicVoice'):
    Voice("e'4", name='MusicVoice')
    Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("e'4"):
    Note("e'4")
    Voice("e'4", name='MusicVoice')
    Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("f'4"):
    Note("f'4")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
AfterGraceContainer("fs'16"):
    AfterGraceContainer("fs'16")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("fs'16"):
    Note("fs'16")
    AfterGraceContainer("fs'16")
    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
orphan

Is true when component has no parent.

REGRESSION. Works with grace notes (and containers):

>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice")
>>> container = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container, music_voice[1])
>>> container = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[2:3])
>>> abjad.attach(abjad.Articulation(">"), container[0])
>>> container = abjad.AfterGraceContainer("fs'16")
>>> abjad.attach(container, music_voice[3])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  
>>> for component in abjad.select.components(staff):
...     parentage = abjad.get.parentage(component)
...     print(f"{repr(component):30} {repr(parentage.orphan)}")
... 
Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }") True
Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice') False
Note("c'4")                    False
BeforeGraceContainer("cs'16")  False
Note("cs'16")                  False
Note("d'4")                    False
Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }") False
OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16") False
Chord("<e' g'>16")             False
Note("gs'16")                  False
Note("a'16")                   False
Note("as'16")                  False
Voice("e'4", name='MusicVoice') False
Note("e'4")                    False
Note("f'4")                    False
AfterGraceContainer("fs'16")   False
Note("fs'16")                  False
parent

Gets parent.

REGRESSION. Works with grace notes (and containers):

>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice")
>>> container = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container, music_voice[1])
>>> container = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[2:3])
>>> abjad.attach(abjad.Articulation(">"), container[0])
>>> container = abjad.AfterGraceContainer("fs'16")
>>> abjad.attach(container, music_voice[3])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  
>>> for component in abjad.select.components(staff):
...     parentage = abjad.get.parentage(component)
...     print(f"{repr(component):30} {repr(parentage.parent)}")
... 
Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }") None
Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice') Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("c'4")                    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
BeforeGraceContainer("cs'16")  Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
Note("cs'16")                  BeforeGraceContainer("cs'16")
Note("d'4")                    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }") Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16") Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }")
Chord("<e' g'>16")             OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16")
Note("gs'16")                  OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16")
Note("a'16")                   OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16")
Note("as'16")                  OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16")
Voice("e'4", name='MusicVoice') Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }")
Note("e'4")                    Voice("e'4", name='MusicVoice')
Note("f'4")                    Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
AfterGraceContainer("fs'16")   Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice')
Note("fs'16")                  AfterGraceContainer("fs'16")
prolation

Gets prolation.

REGRESSION. Works with grace notes (and containers):

>>> music_voice = abjad.Voice(
...     r"\times 2/3 { c'4 d' e' } \times 2/3 { f' g' a' }", name="MusicVoice"
... )
>>> container = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container, music_voice[0][1])
>>> container = abjad.on_beat_grace_container("a'8 b'", music_voice[1][:1])
>>> container = abjad.AfterGraceContainer("fs'16")
>>> abjad.attach(container, music_voice[1][2])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  
>>> for component in abjad.select.components(staff):
...     parentage = abjad.get.parentage(component)
...     print(f"{repr(component):30} {repr(parentage.prolation)}")
... 
Staff("{ { 2/3 c'4 d'4 e'4 } { 2/3 { { <f' a'>8 b'8 } { f'4 } } g'4 a'4 } }") Fraction(1, 1)
Voice("{ 2/3 c'4 d'4 e'4 } { 2/3 { { <f' a'>8 b'8 } { f'4 } } g'4 a'4 }", name='MusicVoice') Fraction(1, 1)
Tuplet('3:2', "c'4 d'4 e'4")   Fraction(2, 3)
Note("c'4")                    Fraction(2, 3)
BeforeGraceContainer("cs'16")  Fraction(2, 3)
Note("cs'16")                  Fraction(2, 3)
Note("d'4")                    Fraction(2, 3)
Note("e'4")                    Fraction(2, 3)
Tuplet('3:2', "{ { <f' a'>8 b'8 } { f'4 } } g'4 a'4") Fraction(2, 3)
Container("{ <f' a'>8 b'8 } { f'4 }") Fraction(2, 3)
OnBeatGraceContainer("<f' a'>8 b'8") Fraction(2, 3)
Chord("<f' a'>8")              Fraction(2, 3)
Note("b'8")                    Fraction(2, 3)
Voice("f'4", name='MusicVoice') Fraction(2, 3)
Note("f'4")                    Fraction(2, 3)
Note("g'4")                    Fraction(2, 3)
Note("a'4")                    Fraction(2, 3)
AfterGraceContainer("fs'16")   Fraction(2, 3)
Note("fs'16")                  Fraction(2, 3)
root

Gets root.

REGRESSION. Works with grace notes (and containers):

>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice")
>>> container = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container, music_voice[1])
>>> container = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[2:3])
>>> abjad.attach(abjad.Articulation(">"), container[0])
>>> container = abjad.AfterGraceContainer("fs'16")
>>> abjad.attach(container, music_voice[3])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  
>>> for component in abjad.select.components(staff):
...     parentage = abjad.get.parentage(component)
...     print(f"{repr(component):30} {repr(parentage.root)}")
... 
Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }") Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Voice("c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4", name='MusicVoice') Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("c'4")                    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
BeforeGraceContainer("cs'16")  Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("cs'16")                  Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("d'4")                    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Container("{ <e' g'>16 gs'16 a'16 as'16 } { e'4 }") Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
OnBeatGraceContainer("<e' g'>16 gs'16 a'16 as'16") Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Chord("<e' g'>16")             Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("gs'16")                  Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("a'16")                   Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("as'16")                  Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Voice("e'4", name='MusicVoice') Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("e'4")                    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("f'4")                    Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
AfterGraceContainer("fs'16")   Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")
Note("fs'16")                  Staff("{ c'4 d'4 { { <e' g'>16 gs'16 a'16 as'16 } { e'4 } } f'4 }")