Selection

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.core" { graph [label="abjad.core"]; node [color=1]; "abjad.core.LogicalTie.LogicalTie" [URL="../api/abjad/core/LogicalTie.html#abjad.core.LogicalTie.LogicalTie", label="Logical\nTie", target=_top]; "abjad.core.Selection.Selection" [URL="../api/abjad/core/Selection.html#abjad.core.Selection.Selection", color=black, fontcolor=white, label=Selection, target=_top]; "abjad.core.Selection.Selection" -> "abjad.core.LogicalTie.LogicalTie"; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/core/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.AbjadValueObject.AbjadValueObject" [URL="../api/abjad/core/../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]; } subgraph "cluster_collections.abc" { graph [label="collections.abc"]; node [color=4]; "collections.abc.Collection" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Collection", label=Collection, shape=oval, style=bold, target=_top]; "collections.abc.Container" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Container", label=Container, shape=oval, style=bold, target=_top]; "collections.abc.Iterable" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Iterable", label=Iterable, shape=oval, style=bold, target=_top]; "collections.abc.Reversible" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Reversible", label=Reversible, shape=oval, style=bold, target=_top]; "collections.abc.Sequence" [URL="https://docs.python.org/3.6/library/collections.abc.html#collections.abc.Sequence", label=Sequence, shape=oval, style=bold, target=_top]; "collections.abc.Sized" [URL="https://docs.python.org/3.6/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"; } "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.core.Selection.Selection"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; "builtins.object" -> "collections.abc.Container"; "builtins.object" -> "collections.abc.Iterable"; "builtins.object" -> "collections.abc.Sized"; "collections.abc.Sequence" -> "abjad.core.Selection.Selection"; }

class abjad.core.Selection.Selection(items=None)

Selection of items (components / or other selections).

Selects runs:

>>> string = r"c'4 \times 2/3 { d'8 r8 e'8 } r16 f'16 g'8 a'4"
>>> staff = abjad.Staff(string)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).runs()
>>> for item in result:
...     item
... 
Selection([Note("c'4"), Note("d'8")])
Selection([Note("e'8")])
Selection([Note("f'16"), Note("g'8"), Note("a'4")])
>>> selector = abjad.select().runs()
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'4"), Note("d'8")])
Selection([Note("e'8")])
Selection([Note("f'16"), Note("g'8"), Note("a'4")])
>>> selector.color(result)
>>> abjad.show(staff) 

Attributes Summary

__add__ Cocatenates argument to selection.
__contains__ Is true when argument is in selection.
__eq__ Is true when selection and argument are of the same type and when items in selection equal item in argument.
__format__ Formats duration.
__getitem__ Gets item, slice or pattern argument in selection.
__hash__ Hashes selection.
__illustrate__ Attempts to illustrate selection.
__len__ Gets number of items in selection.
__radd__ Concatenates selection to argument.
__repr__ Gets interpreter representation of selection.
are_contiguous_logical_voice Is true when items in selection are contiguous components in the same logical voice.
are_contiguous_same_parent Is true when items in selection are all contiguous components in the same parent.
are_leaves Is true when items in selection are all leaves.
are_logical_voice Is true when items in selection are all components in the same logical voice.
chord Selects chord n.
chords Selects chords.
components Selects components.
filter Filters selection by predicate.
filter_duration Filters selection by operator and duration.
filter_length Filters selection by operator and length.
filter_pitches Filters selection by operator and pitches.
filter_preprolated Filters selection by operator and preprolated duration.
flatten Flattens selection to depth.
group Groups selection.
group_by Groups items in selection by predicate.
group_by_contiguity Groups items in selection by contiguity.
group_by_duration Groups items in selection by duration.
group_by_length Groups items in selection by length.
group_by_measure Groups items in selection by measure.
group_by_pitch Groups items in selection by pitches.
items Gets items.
leaf Selects leaf n.
leaves Selects leaves (without grace notes).
logical_ties Selects logical ties (without grace notes).
map Maps expression to items in selection.
nontrivial Filters selection by length greater than 1.
note Selects note n.
notes Selects notes.
partition_by_counts Partitions selection by counts.
partition_by_durations Partitions selection by durations.
partition_by_ratio Partitions selection by ratio.
rest Selects rest n.
rests Selects rests.
run Selects run n.
runs Selects runs.
top Selects top components.
tuplet Selects tuplet n.
tuplets Selects tuplets.
with_next_leaf Extends selection with next leaf.
with_previous_leaf Extends selection with previous leaf.

Special methods

__add__(argument)

Cocatenates argument to selection.

Returns new selection.

__contains__(argument)

Is true when argument is in selection.

Returns true or false.

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

__eq__(argument)

Is true when selection and argument are of the same type and when items in selection equal item in argument.

Returns true or false.

__format__(format_specification='')

Formats duration.

Returns string.

__getitem__(argument)

Gets item, slice or pattern argument in selection.

Gets every other leaf:

>>> string = r"c'8 d'8 ~ d'8 e'8 ~ e'8 ~ e'8 r8 f'8"
>>> staff = abjad.Staff(string)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> pattern = abjad.index([0], 2)
>>> for leaf in abjad.select(staff).leaves()[pattern]:
...     leaf
... 
Note("c'8")
Note("d'8")
Note("e'8")
Rest('r8')
>>> selector = abjad.select().leaves()[pattern]
>>> result = selector(staff)
>>> selector.print(result)
Note("c'8")
Note("d'8")
Note("e'8")
Rest('r8')
>>> selector.color(result)
>>> abjad.show(staff) 

Gets every other logical tie:

>>> string = r"c'8 d'8 ~ d'8 e'8 ~ e'8 ~ e'8 r8 f'8"
>>> staff = abjad.Staff(string)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> pattern = abjad.index([0], 2)
>>> selection = abjad.select(staff).logical_ties(pitched=True)
>>> for logical_tie in selection[pattern]:
...     logical_tie
... 
LogicalTie([Note("c'8")])
LogicalTie([Note("e'8"), Note("e'8"), Note("e'8")])
>>> selector = abjad.select().logical_ties(pitched=True)
>>> selector = selector[pattern]
>>> result = selector(staff)
>>> selector.print(result)
LogicalTie([Note("c'8")])
LogicalTie([Note("e'8"), Note("e'8"), Note("e'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Gets note 1 (or nothing) in each pitched logical tie:

>>> staff = abjad.Staff(r"c'8 d'8 ~ d'8 e'8 ~ e'8 ~ e'8 r8 f'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> getter = abjad.select().leaves()[abjad.index([1])]
>>> for selection in abjad.select(staff).logical_ties(
...     pitched=True,
...     ).map(getter):
...     selection
... 
Selection(items=())
Selection([Note("d'8")])
Selection([Note("e'8")])
Selection(items=())
>>> getter = abjad.select().leaves()[abjad.index([1])]
>>> selector = abjad.select().logical_ties(pitched=True)
>>> selector = selector.map(getter)
>>> result = selector(staff)
>>> selector.print(result)
Selection(items=())
Selection([Note("d'8")])
Selection([Note("e'8")])
Selection(items=())
>>> selector.color(result)
>>> abjad.show(staff) 
>>> abjad.select().leaves()[:2]
abjad.select().leaves()[:2]

Returns a single item (or expression) when argument is an integer.

Returns new selection (or expression) when argument is a slice.

Returns new selection (or expression) when argument is a pattern.

__hash__()

Hashes selection.

Redefined in tandem with __eq__.

__illustrate__()

Attempts to illustrate selection.

Evaluates the storage format of the selection (to sever any references to the source score from which the selection was taken). Then tries to wrap the result in a staff; in the case that notes of only C4 are found then sets the staff context name to 'RhythmicStaff'. If this works then the staff is wrapped in a LilyPond file and the file is returned. If this doesn’t work then the method raises an exception.

The idea is that the illustration should work for simple selections of that represent an essentially contiguous snippet of a single voice of music.

Returns LilyPond file.

(Sequence).__iter__()
__len__()

Gets number of items in selection.

Returns nonnegative integer.

__radd__(argument)

Concatenates selection to argument.

Returns newly created selection.

__repr__()

Gets interpreter representation of selection.

Returns string.

(Sequence).__reversed__()

Methods

are_contiguous_logical_voice(prototype=None, allow_orphans=True)

Is true when items in selection are contiguous components in the same logical voice.

>>> staff = abjad.Staff("c'4 d'4 e'4 f'4")
>>> staff[:].are_contiguous_logical_voice()
True
>>> selection = staff[:1] + staff[-1:]
>>> selection.are_contiguous_logical_voice()
False

Returns true or false.

are_contiguous_same_parent(prototype=None, allow_orphans=True)

Is true when items in selection are all contiguous components in the same parent.

>>> staff = abjad.Staff("c'4 d'4 e'4 f'4")
>>> staff[:].are_contiguous_same_parent()
True
>>> selection = staff[:1] + staff[-1:]
>>> selection.are_contiguous_same_parent()
False

Returns true or false.

are_leaves()

Is true when items in selection are all leaves.

>>> abjad.Staff("c'4 d'4 e'4 f'4")[:].are_leaves()
True

Returns true or false.

are_logical_voice(prototype=None, allow_orphans=True)

Is true when items in selection are all components in the same logical voice.

>>> staff = abjad.Staff("c'4 d'4 e'4 f'4")
>>> staff[:].are_logical_voice()
True
>>> selection = staff[:1] + staff[-1:]
>>> selection.are_logical_voice()
True

Returns true or false.

chord(n)

Selects chord n.

Selects chord -1:

>>> tuplets = [
...     "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> result = abjad.select(staff).chord(-1)
>>> result
Chord("<fs' gs'>16")
>>> selector = abjad.select().chord(-1)
>>> result = selector(staff)
>>> selector.print(result)
Chord("<fs' gs'>16")
>>> selector.color(result)
>>> abjad.show(lilypond_file) 
chords()

Selects chords.

Selects chords:

>>> tuplets = [
...     "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> result = abjad.select(staff).chords()
>>> for item in result:
...     item
... 
Chord("<a'' b''>16")
Chord("<d' e'>4")
Chord("<d' e'>16")
Chord("<a'' b''>16")
Chord("<e' fs'>4")
Chord("<e' fs'>16")
Chord("<a'' b''>16")
Chord("<fs' gs'>4")
Chord("<fs' gs'>16")
>>> selector = abjad.select().chords()
>>> result = selector(staff)
>>> selector.print(result)
Chord("<a'' b''>16")
Chord("<d' e'>4")
Chord("<d' e'>16")
Chord("<a'' b''>16")
Chord("<e' fs'>4")
Chord("<e' fs'>16")
Chord("<a'' b''>16")
Chord("<fs' gs'>4")
Chord("<fs' gs'>16")
>>> selector.color(result)
>>> abjad.show(lilypond_file) 
components(prototype=None, grace_notes=None, reverse=False)

Selects components.

Selects notes:

>>> staff = abjad.Staff("c'4 d'8 ~ d'16 e'16 ~ e'8 r4 g'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).components(abjad.Note)
>>> for item in result:
...     item
... 
Note("c'4")
Note("d'8")
Note("d'16")
Note("e'16")
Note("e'8")
Note("g'8")
>>> selector = abjad.select().components(abjad.Note)
>>> result = selector(staff)
>>> selector.color(result)
>>> abjad.show(staff) 
>>> selector.print(result)
Note("c'4")
Note("d'8")
Note("d'16")
Note("e'16")
Note("e'8")
Note("g'8")

Returns new selection (or expression).

(Sequence).count(value) → integer -- return number of occurrences of value
filter(predicate=None)

Filters selection by predicate.

Selects runs with duration equal to 2/8:

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> inequality = abjad.DurationInequality('==', (2, 8))
>>> result = abjad.select(staff).runs().filter(inequality)
>>> for item in result:
...     item
... 
Selection([Note("d'8"), Note("e'8")])
>>> selector = abjad.select().runs().filter(inequality)
>>> result = selector(staff)
>>> selector.color(result)
>>> abjad.show(staff) 
>>> selector.print(result)
Selection([Note("d'8"), Note("e'8")])

Returns new selection (or expression).

filter_duration(operator, duration)

Filters selection by operator and duration.

Selects runs with duration equal to 2/8:

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).runs()
>>> result = result.filter_duration('==', (2, 8))
>>> for item in result:
...     item
... 
Selection([Note("d'8"), Note("e'8")])
>>> selector = abjad.select().runs()
>>> selector = selector.filter_duration('==', (2, 8))
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("d'8"), Note("e'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Selects runs with duration less than 3/8:

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).runs()
>>> result = result.filter_duration('<', (3, 8))
>>> for item in result:
...     item
... 
Selection([Note("c'8")])
Selection([Note("d'8"), Note("e'8")])
>>> selector = abjad.select().runs()
>>> selector = selector.filter_duration('<', (3, 8))
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8")])
Selection([Note("d'8"), Note("e'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Returns new selection (or expression).

filter_length(operator, length)

Filters selection by operator and length.

Selects notes runs with length greater than 1:

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).runs().filter_length('>', 1)
>>> for item in result:
...     item
... 
Selection([Note("d'8"), Note("e'8")])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector = abjad.select().runs().filter_length('>', 1)
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("d'8"), Note("e'8")])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Selects runs with length less than 3:

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).runs().filter_length('<', 3)
>>> for item in result:
...     item
... 
Selection([Note("c'8")])
Selection([Note("d'8"), Note("e'8")])
>>> selector = abjad.select().runs().filter_length('<', 3)
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8")])
Selection([Note("d'8"), Note("e'8")])
>>> selector.color(result)
>>> abjad.show(staff) 
filter_pitches(operator, pitches)

Filters selection by operator and pitches.

Selects leaves with pitches intersecting C4:

>>> staff = abjad.Staff("c'8 d'8 ~ d'8 e'8")
>>> abjad.setting(staff).auto_beaming = False
>>> staff.extend("r8 <c' e' g'>8 ~ <c' e' g'>4")
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.filter_pitches('&', 'C4')
>>> for item in result:
...     item
... 
Note("c'8")
Chord("<c' e' g'>8")
Chord("<c' e' g'>4")
>>> selector = abjad.select().leaves()
>>> selector = selector.filter_pitches('&', 'C4')
>>> result = selector(staff)
>>> selector.print(result)
Note("c'8")
Chord("<c' e' g'>8")
Chord("<c' e' g'>4")
>>> selector.color(result)
>>> abjad.show(staff) 

Selects leaves with pitches intersecting C4 or E4:

>>> staff = abjad.Staff("c'8 d'8 ~ d'8 e'8")
>>> abjad.setting(staff).auto_beaming = False
>>> staff.extend("r8 <c' e' g'>8 ~ <c' e' g'>4")
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.filter_pitches('&', 'C4 E4')
>>> for item in result:
...     item
... 
Note("c'8")
Note("e'8")
Chord("<c' e' g'>8")
Chord("<c' e' g'>4")
>>> selector = abjad.select().leaves()
>>> selector = selector.filter_pitches('&', 'C4 E4')
>>> result = selector(staff)
>>> selector.print(result)
Note("c'8")
Note("e'8")
Chord("<c' e' g'>8")
Chord("<c' e' g'>4")
>>> selector.color(result)
>>> abjad.show(staff) 

Selects logical ties with pitches intersecting C4:

>>> staff = abjad.Staff("c'8 d'8 ~ d'8 e'8")
>>> abjad.setting(staff).auto_beaming = False
>>> staff.extend("r8 <c' e' g'>8 ~ <c' e' g'>4")
>>> abjad.show(staff) 
>>> result = abjad.select(staff).logical_ties()
>>> result = result.filter_pitches('&', 'C4')
>>> for item in result:
...     item
... 
LogicalTie([Note("c'8")])
LogicalTie([Chord("<c' e' g'>8"), Chord("<c' e' g'>4")])
>>> selector = abjad.select().logical_ties()
>>> selector = selector.filter_pitches('&', 'C4')
>>> result = selector(staff)
>>> selector.print(result)
LogicalTie([Note("c'8")])
LogicalTie([Chord("<c' e' g'>8"), Chord("<c' e' g'>4")])
>>> selector.color(result)
>>> abjad.show(staff) 

Returns new selection (or expression).

filter_preprolated(operator, duration)

Filters selection by operator and preprolated duration.

Selects runs with duration equal to 2/8:

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).runs()
>>> result = result.filter_preprolated('==', (2, 8))
>>> for item in result:
...     item
... 
Selection([Note("d'8"), Note("e'8")])
>>> selector = abjad.select().runs()
>>> selector = selector.filter_preprolated('==', (2, 8))
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("d'8"), Note("e'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Selects runs with duration less than 3/8:

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).runs()
>>> result = result.filter_preprolated('<', (3, 8))
>>> for item in result:
...     item
... 
Selection([Note("c'8")])
Selection([Note("d'8"), Note("e'8")])
>>> selector = abjad.select().runs()
>>> selector = selector.filter_preprolated('<', (3, 8))
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8")])
Selection([Note("d'8"), Note("e'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Returns new selection (or expression).

flatten(depth=1)

Flattens selection to depth.

Selects first two leaves of each tuplet:

>>> tuplets = [
...     "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> getter = abjad.select().leaves()[:2]
>>> result = abjad.select(staff).tuplets().map(getter)
>>> for item in result:
...     item
... 
Selection([Rest('r16'), Note("bf'16")])
Selection([Rest('r16'), Note("bf'16")])
Selection([Rest('r16'), Note("bf'16")])
>>> selector = abjad.select().tuplets().map(getter)
>>> result = selector(staff)
>>> selector.print(result)
Selection([Rest('r16'), Note("bf'16")])
Selection([Rest('r16'), Note("bf'16")])
Selection([Rest('r16'), Note("bf'16")])
>>> selector.color(result)
>>> abjad.show(lilypond_file) 

Selects first two leaves of all tuplets:

>>> tuplets = [
...     "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> getter = abjad.select().leaves()[:2]
>>> result = abjad.select(staff).tuplets().map(getter)
>>> result = result.flatten()
>>> for item in result:
...     item
... 
Rest('r16')
Note("bf'16")
Rest('r16')
Note("bf'16")
Rest('r16')
Note("bf'16")
>>> selector = abjad.select().tuplets().map(getter).flatten()
>>> result = selector(staff)
>>> selector.print(result)
Rest('r16')
Note("bf'16")
Rest('r16')
Note("bf'16")
Rest('r16')
Note("bf'16")
>>> selector.color(result)
>>> abjad.show(lilypond_file) 

Returns new selection (or expression).

group()

Groups selection.

>>> staff = abjad.Staff(r'''
...     c'8 ~ c'16 c'16 r8 c'16 c'16
...     d'8 ~ d'16 d'16 r8 d'16 d'16
...     ''')
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff, strict=89) 
>>> result = abjad.select(staff).leaves(pitched=True).group()
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("c'16"), Note("c'16"), Note("c'16"), Note("c'16"), Note("d'8"), Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")])
>>> selector = abjad.select().leaves(pitched=True).group()
>>> result = selector(staff)
>>> selector.print(result)
Selection([Selection([Note("c'8"), Note("c'16"), Note("c'16"), Note("c'16"), Note("c'16"), Note("d'8"), Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")])])
>>> selector.color(result)
>>> abjad.show(staff, strict=89) 

Returns nested selection (or expression).

group_by(predicate=None)

Groups items in selection by predicate.

Wraps selection in selection when predicate is none:

>>> staff = abjad.Staff(r"""
...     c'8 ~ c'16 c'16 r8 c'16 c'16
...     d'8 ~ d'16 d'16 r8 d'16 d'16
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves(pitched=True)
>>> result = result.group_by()
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("c'16"), Note("c'16"), Note("c'16"), Note("c'16"), Note("d'8"), Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")])
>>> selector = abjad.select().leaves(pitched=True).group_by()
>>> result = selector(staff)
>>> selector.print(result)
Selection([Selection([Note("c'8"), Note("c'16"), Note("c'16"), Note("c'16"), Note("c'16"), Note("d'8"), Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")])])
>>> selector.color(result)
>>> abjad.show(staff) 

Returns nested selection (or expression).

group_by_contiguity()

Groups items in selection by contiguity.

Groups pitched leaves by contiguity:

>>> string = r"c'8 d' r \times 2/3 { e' r f' } g' a' r"
>>> staff = abjad.Staff(string)
>>> abjad.setting(staff).auto_beaming = False
>>> staff.extend("r8 <c' e' g'>8 ~ <c' e' g'>4")
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves(pitched=True)
>>> result = result.group_by_contiguity()
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("d'8")])
Selection([Note("e'8")])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
Selection([Chord("<c' e' g'>8"), Chord("<c' e' g'>4")])
>>> selector = abjad.select().leaves(pitched=True)
>>> selector = selector.group_by_contiguity()
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Note("d'8")])
Selection([Note("e'8")])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
Selection([Chord("<c' e' g'>8"), Chord("<c' e' g'>4")])
>>> selector.color(result)
>>> abjad.show(staff) 

Groups sixteenths by contiguity:

>>> staff = abjad.Staff("c'4 d'16 d' d' d' e'4 f'16 f' f' f'")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.filter_duration('==', (1, 16))
>>> result = result.group_by_contiguity()
>>> for item in result:
...     item
... 
Selection([Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")])
Selection([Note("f'16"), Note("f'16"), Note("f'16"), Note("f'16")])
>>> selector = abjad.select().leaves()
>>> selector = selector.filter_duration('==', (1, 16))
>>> selector = selector.group_by_contiguity()
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")])
Selection([Note("f'16"), Note("f'16"), Note("f'16"), Note("f'16")])
>>> selector.color(result)
>>> abjad.show(staff) 

Groups short-duration logical ties by contiguity; then gets leaf 0 in each group:

>>> staff = abjad.Staff("c'4 d'8 ~ d'16 e'16 ~ e'8 f'4 g'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).logical_ties()
>>> result = result.filter_duration('<', (1, 4))
>>> result = result.group_by_contiguity()
>>> result = result.map(abjad.select().leaves()[0])
>>> for item in result:
...     item
... 
Note("d'8")
Note("g'8")
>>> selector = abjad.select().logical_ties()
>>> selector = selector.filter_duration('<', (1, 4))
>>> selector = selector.group_by_contiguity()
>>> selector = selector.map(abjad.select().leaves()[0])
>>> result = selector(staff)
>>> selector.print(result)
Note("d'8")
Note("g'8")
>>> selector.color(result)
>>> abjad.show(staff) 

Groups pitched leaves pitch; then regroups each group by contiguity:

>>> staff = abjad.Staff(r"""
...     c'8 ~ c'16 c'16 r8 c'16 c'16
...     d'8 ~ d'16 d'16 r8 d'16 d'16
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves(pitched=True)
>>> result = result.group_by_pitch()
>>> result = result.map(abjad.select().group_by_contiguity())
>>> result = result.flatten()
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("c'16"), Note("c'16")])
Selection([Note("c'16"), Note("c'16")])
Selection([Note("d'8"), Note("d'16"), Note("d'16")])
Selection([Note("d'16"), Note("d'16")])
>>> selector = abjad.select().leaves(pitched=True)
>>> selector = selector.group_by_pitch()
>>> selector = selector.map(
...     abjad.select().group_by_contiguity()
...     )
>>> selector = selector.flatten()
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Note("c'16"), Note("c'16")])
Selection([Note("c'16"), Note("c'16")])
Selection([Note("d'8"), Note("d'16"), Note("d'16")])
Selection([Note("d'16"), Note("d'16")])
>>> selector.color(result)
>>> abjad.show(staff) 

Groups pitched logical ties by contiguity; then regroups each group by pitch:

>>> staff = abjad.Staff(r"""
...     c'8 ~ c'16 c'16 r8 c'16 c'16
...     d'8 ~ d'16 d'16 r8 d'16 d'16
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> getter = abjad.select().group_by_pitch()
>>> result = abjad.select(staff).logical_ties(pitched=True)
>>> result = result.group_by_contiguity()
>>> result = result.map(getter).flatten()
>>> for item in result:
...     item
... 
Selection([LogicalTie([Note("c'8"), Note("c'16")]), LogicalTie([Note("c'16")])])
Selection([LogicalTie([Note("c'16")]), LogicalTie([Note("c'16")])])
Selection([LogicalTie([Note("d'8"), Note("d'16")]), LogicalTie([Note("d'16")])])
Selection([LogicalTie([Note("d'16")]), LogicalTie([Note("d'16")])])
>>> selector = abjad.select().logical_ties(pitched=True)
>>> selector = selector.group_by_contiguity()
>>> selector = selector.map(getter).flatten()
>>> result = selector(staff)
>>> selector.print(result)
Selection([LogicalTie([Note("c'8"), Note("c'16")]), LogicalTie([Note("c'16")])])
Selection([LogicalTie([Note("c'16")]), LogicalTie([Note("c'16")])])
Selection([LogicalTie([Note("d'8"), Note("d'16")]), LogicalTie([Note("d'16")])])
Selection([LogicalTie([Note("d'16")]), LogicalTie([Note("d'16")])])
>>> selector.color(result)
>>> abjad.show(staff) 

Returns new selection (or expression).

group_by_duration()

Groups items in selection by duration.

Groups logical ties by duration:

>>> string = "c'4 ~ c'16 d' ~ d' d' e'4 ~ e'16 f' ~ f' f'"
>>> staff = abjad.Staff(string)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).logical_ties()
>>> result = result.group_by_duration()
>>> for item in result:
...     item
... 
Selection([LogicalTie([Note("c'4"), Note("c'16")])])
Selection([LogicalTie([Note("d'16"), Note("d'16")])])
Selection([LogicalTie([Note("d'16")])])
Selection([LogicalTie([Note("e'4"), Note("e'16")])])
Selection([LogicalTie([Note("f'16"), Note("f'16")])])
Selection([LogicalTie([Note("f'16")])])
>>> selector = abjad.select().logical_ties().group_by_duration()
>>> result = selector(staff)
>>> selector.print(result)
Selection([LogicalTie([Note("c'4"), Note("c'16")])])
Selection([LogicalTie([Note("d'16"), Note("d'16")])])
Selection([LogicalTie([Note("d'16")])])
Selection([LogicalTie([Note("e'4"), Note("e'16")])])
Selection([LogicalTie([Note("f'16"), Note("f'16")])])
Selection([LogicalTie([Note("f'16")])])
>>> selector.color(result)
>>> abjad.show(staff) 

Returns nested selection (or expression).

group_by_length()

Groups items in selection by length.

Groups logical ties by length:

>>> string = "c'4 ~ c'16 d' ~ d' d' e'4 ~ e'16 f' ~ f' f'"
>>> staff = abjad.Staff(string)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).logical_ties().group_by_length()
>>> for item in result:
...     item
... 
Selection([LogicalTie([Note("c'4"), Note("c'16")]), LogicalTie([Note("d'16"), Note("d'16")])])
Selection([LogicalTie([Note("d'16")])])
Selection([LogicalTie([Note("e'4"), Note("e'16")]), LogicalTie([Note("f'16"), Note("f'16")])])
Selection([LogicalTie([Note("f'16")])])
>>> selector = abjad.select().logical_ties().group_by_length()
>>> result = selector(staff)
>>> selector.print(result)
Selection([LogicalTie([Note("c'4"), Note("c'16")]), LogicalTie([Note("d'16"), Note("d'16")])])
Selection([LogicalTie([Note("d'16")])])
Selection([LogicalTie([Note("e'4"), Note("e'16")]), LogicalTie([Note("f'16"), Note("f'16")])])
Selection([LogicalTie([Note("f'16")])])
>>> selector.color(result)
>>> abjad.show(staff) 

Returns nested selection (or expression).

group_by_measure()

Groups items in selection by measure.

Groups leaves by logical measure:

>>> staff = abjad.Staff("c'8 d' e' f' g' a' b' c''")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.attach(abjad.TimeSignature((2, 8)), staff[0])
>>> abjad.attach(abjad.TimeSignature((3, 8)), staff[4])
>>> abjad.attach(abjad.TimeSignature((1, 8)), staff[7])
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.group_by_measure()
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("d'8")])
Selection([Note("e'8"), Note("f'8")])
Selection([Note("g'8"), Note("a'8"), Note("b'8")])
Selection([Note("c''8")])
>>> selector = abjad.select().leaves()
>>> selector = selector.group_by_measure()
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Note("d'8")])
Selection([Note("e'8"), Note("f'8")])
Selection([Note("g'8"), Note("a'8"), Note("b'8")])
Selection([Note("c''8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Groups leaves by logical measure and joins pairs of consecutive groups:

>>> staff = abjad.Staff("c'8 d' e' f' g' a' b' c''")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.attach(abjad.TimeSignature((2, 8)), staff[0])
>>> abjad.attach(abjad.TimeSignature((3, 8)), staff[4])
>>> abjad.attach(abjad.TimeSignature((1, 8)), staff[7])
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.group_by_measure()
>>> result = result.partition_by_counts([2], cyclic=True)
>>> result = result.map(abjad.select().flatten())
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("d'8"), Note("e'8"), Note("f'8")])
Selection([Note("g'8"), Note("a'8"), Note("b'8"), Note("c''8")])
>>> selector = abjad.select().leaves()
>>> selector = selector.group_by_measure()
>>> selector = selector.partition_by_counts([2], cyclic=True)
>>> selector = selector.map(abjad.select().flatten())
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Note("d'8"), Note("e'8"), Note("f'8")])
Selection([Note("g'8"), Note("a'8"), Note("b'8"), Note("c''8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Groups leaves by logical measure; then gets item 0 in each group:

>>> staff = abjad.Staff("c'8 d' e' f' g' a' b' c''")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.attach(abjad.TimeSignature((2, 8)), staff[0])
>>> abjad.attach(abjad.TimeSignature((3, 8)), staff[4])
>>> abjad.attach(abjad.TimeSignature((1, 8)), staff[7])
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.group_by_measure()
>>> result = result.map(abjad.select()[0])
>>> for item in result:
...     item
... 
Note("c'8")
Note("e'8")
Note("g'8")
Note("c''8")
>>> selector = abjad.select().leaves()
>>> selector = selector.group_by_measure()
>>> selector = selector.map(abjad.select()[0])
>>> result = selector(staff)
>>> selector.print(result)
Note("c'8")
Note("e'8")
Note("g'8")
Note("c''8")
>>> selector.color(result)
>>> abjad.show(staff) 

Groups leaves by logical measure; then gets item -1 in each group:

>>> staff = abjad.Staff("c'8 d' e' f' g' a' b' c''")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.attach(abjad.TimeSignature((2, 8)), staff[0])
>>> abjad.attach(abjad.TimeSignature((3, 8)), staff[4])
>>> abjad.attach(abjad.TimeSignature((1, 8)), staff[7])
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.group_by_measure()
>>> result = result.map(abjad.select()[-1])
>>> for item in result:
...     item
... 
Note("d'8")
Note("f'8")
Note("b'8")
Note("c''8")
>>> selector = abjad.select().leaves()
>>> selector = selector.group_by_measure()
>>> selector = selector.map(abjad.select()[-1])
>>> result = selector(staff)
>>> selector.print(result)
Note("d'8")
Note("f'8")
Note("b'8")
Note("c''8")
>>> selector.color(result)
>>> abjad.show(staff) 

Works with implicit time signatures:

>>> staff = abjad.Staff("c'4 d' e' f' g' a' b' c''")
>>> abjad.setting(staff).auto_beaming = False
>>> score = abjad.Score([staff])
>>> scheme = abjad.SchemeMoment((1, 16))
>>> abjad.setting(score).proportional_notation_duration = scheme
>>> abjad.show(score) 
>>> result = abjad.select(score).leaves()
>>> result = result.group_by_measure()
>>> for item in result:
...     item
... 
Selection([Note("c'4"), Note("d'4"), Note("e'4"), Note("f'4")])
Selection([Note("g'4"), Note("a'4"), Note("b'4"), Note("c''4")])
>>> selector = abjad.select().leaves()
>>> selector = selector.group_by_measure()
>>> result = selector(score)
>>> selector.print(result)
Selection([Note("c'4"), Note("d'4"), Note("e'4"), Note("f'4")])
Selection([Note("g'4"), Note("a'4"), Note("b'4"), Note("c''4")])
>>> selector.color(result)
>>> abjad.show(staff) 

Returns new selection (or expression).

group_by_pitch()

Groups items in selection by pitches.

Groups logical ties by pitches:

>>> string = "c'4 ~ c'16 d' ~ d' d' e'4 ~ e'16 f' ~ f' f'"
>>> staff = abjad.Staff(string)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).logical_ties().group_by_pitch()
>>> for item in result:
...     item
... 
Selection([LogicalTie([Note("c'4"), Note("c'16")])])
Selection([LogicalTie([Note("d'16"), Note("d'16")]), LogicalTie([Note("d'16")])])
Selection([LogicalTie([Note("e'4"), Note("e'16")])])
Selection([LogicalTie([Note("f'16"), Note("f'16")]), LogicalTie([Note("f'16")])])
>>> selector = abjad.select().logical_ties().group_by_pitch()
>>> result = selector(staff)
>>> selector.print(result)
Selection([LogicalTie([Note("c'4"), Note("c'16")])])
Selection([LogicalTie([Note("d'16"), Note("d'16")]), LogicalTie([Note("d'16")])])
Selection([LogicalTie([Note("e'4"), Note("e'16")])])
Selection([LogicalTie([Note("f'16"), Note("f'16")]), LogicalTie([Note("f'16")])])
>>> selector.color(result)
>>> abjad.show(staff) 

Returns nested selection (or expression).

(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.

leaf(n)

Selects leaf n.

Selects leaf -1:

>>> tuplets = [
...     "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> result = abjad.select(staff).leaf(-1)
>>> result
Chord("<fs' gs'>16")
>>> selector = abjad.select().leaf(-1)
>>> result = selector(staff)
>>> selector.print(result)
Chord("<fs' gs'>16")
>>> selector.color(result)
>>> abjad.show(lilypond_file) 
leaves(prototype=None, grace_notes=False, head=None, pitched=None, reverse=False, tail=None, trim=None)

Selects leaves (without grace notes).

Selects leaves:

>>> staff = abjad.Staff(r"""
...     \times 2/3 { r8 d' e' } f' r
...     r f' \times 2/3 { e' d' r8 }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> for item in result:
...     item
... 
Rest('r8')
Note("d'8")
Note("e'8")
Note("f'8")
Rest('r8')
Rest('r8')
Note("f'8")
Note("e'8")
Note("d'8")
Rest('r8')
>>> selector = abjad.select().leaves()
>>> result = selector(staff)
>>> selector.print(result)
Rest('r8')
Note("d'8")
Note("e'8")
Note("f'8")
Rest('r8')
Rest('r8')
Note("f'8")
Note("e'8")
Note("d'8")
Rest('r8')
>>> selector.color(result)
>>> abjad.show(staff) 

Selects pitched leaves:

>>> staff = abjad.Staff(r"""
...     \times 2/3 { r8 d' e' } f' r
...     r f' \times 2/3 { e' d' r8 }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves(pitched=True)
>>> for item in result:
...     item
... 
Note("d'8")
Note("e'8")
Note("f'8")
Note("f'8")
Note("e'8")
Note("d'8")
>>> selector = abjad.select().leaves(pitched=True)
>>> result = selector(staff)
>>> selector.print(result)
Note("d'8")
Note("e'8")
Note("f'8")
Note("f'8")
Note("e'8")
Note("d'8")
>>> selector.color(result)
>>> abjad.show(staff) 

Trimmed leaves are the correct selection for ottava spanners.

Selects trimmed leaves:

>>> staff = abjad.Staff(r"""
...     \times 2/3 { r8 d' e' } f' r
...     r f' \times 2/3 { e' d' r8 }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves(trim=True)
>>> for item in result:
...     item
... 
Note("d'8")
Note("e'8")
Note("f'8")
Rest('r8')
Rest('r8')
Note("f'8")
Note("e'8")
Note("d'8")
>>> selector = abjad.select().leaves(trim=True)
>>> result = selector(staff)
>>> selector.print(result)
Note("d'8")
Note("e'8")
Note("f'8")
Rest('r8')
Rest('r8')
Note("f'8")
Note("e'8")
Note("d'8")
>>> abjad.attach(abjad.OctavationSpanner(), result)
>>> selector.color(result)
>>> abjad.show(staff) 

Set trim to abjad.Left to trim rests at left (and preserve rests at right):

>>> staff = abjad.Staff(r"""
...     \times 2/3 { r8 d' e' } f' r
...     r f' \times 2/3 { e' d' r8 }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves(trim=abjad.Left)
>>> for item in result:
...     item
... 
Note("d'8")
Note("e'8")
Note("f'8")
Rest('r8')
Rest('r8')
Note("f'8")
Note("e'8")
Note("d'8")
Rest('r8')
>>> selector = abjad.select().leaves(trim=abjad.Left)
>>> result = selector(staff)
>>> selector.print(result)
Note("d'8")
Note("e'8")
Note("f'8")
Rest('r8')
Rest('r8')
Note("f'8")
Note("e'8")
Note("d'8")
Rest('r8')
>>> abjad.attach(abjad.OctavationSpanner(), result)
>>> selector.color(result)
>>> abjad.show(staff) 

REGRESSION: selects trimmed leaves (even when there are no rests to trim):

>>> staff = abjad.Staff(r"""
...     \times 2/3 { c'8 d' e' } f' r
...     r f' \times 2/3 { e' d' c' }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves(trim=True)
>>> for item in result:
...     item
... 
Note("c'8")
Note("d'8")
Note("e'8")
Note("f'8")
Rest('r8')
Rest('r8')
Note("f'8")
Note("e'8")
Note("d'8")
Note("c'8")
>>> selector = abjad.select().leaves(trim=True)
>>> result = selector(staff)
>>> selector.print(result)
Note("c'8")
Note("d'8")
Note("e'8")
Note("f'8")
Rest('r8')
Rest('r8')
Note("f'8")
Note("e'8")
Note("d'8")
Note("c'8")
>>> selector.color(result)
>>> abjad.show(staff) 

Selects leaves in tuplets:

>>> staff = abjad.Staff(r"""
...     \times 2/3 { r8 d' e' } f' r
...     r f' \times 2/3 { e' d' r8 }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).components(abjad.Tuplet)
>>> result = result.leaves()
>>> for item in result:
...     item
... 
Rest('r8')
Note("d'8")
Note("e'8")
Note("e'8")
Note("d'8")
Rest('r8')
>>> selector = abjad.select().components(abjad.Tuplet)
>>> selector = selector.leaves()
>>> result = selector(staff)
>>> selector.print(result)
Rest('r8')
Note("d'8")
Note("e'8")
Note("e'8")
Note("d'8")
Rest('r8')
>>> selector.color(result)
>>> abjad.show(staff) 

Selects trimmed leaves in tuplets:

>>> staff = abjad.Staff(r"""
...     \times 2/3 { r8 d' e' } f' r
...     r f' \times 2/3 { e' d' r8 }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).components(abjad.Tuplet)
>>> result = result.leaves(trim=True)
>>> for item in result:
...     item
... 
Note("d'8")
Note("e'8")
Note("e'8")
Note("d'8")
>>> selector = abjad.select().components(abjad.Tuplet)
>>> selector = selector.leaves(trim=True)
>>> result = selector(staff)
>>> selector.print(result)
Note("d'8")
Note("e'8")
Note("e'8")
Note("d'8")
>>> selector.color(result)
>>> abjad.show(staff) 

Pitched heads is the correct selection for most articulations.

Selects pitched heads in tuplets:

>>> staff = abjad.Staff(r"""
...     \times 2/3 { c'8 d' ~ d' } e' r
...     r e' \times 2/3 { d' ~ d' c' }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).components(abjad.Tuplet)
>>> result = result.leaves(head=True, pitched=True)
>>> for item in result:
...     item
... 
Note("c'8")
Note("d'8")
Note("d'8")
Note("c'8")
>>> selector = abjad.select().components(abjad.Tuplet)
>>> selector = selector.leaves(head=True, pitched=True)
>>> result = selector(staff)
>>> selector.print(result)
Note("c'8")
Note("d'8")
Note("d'8")
Note("c'8")
>>> selector.color(result)
>>> abjad.show(staff) 

Pitched tails in the correct selection for laissez vibrer.

Selects pitched tails in tuplets:

>>> staff = abjad.Staff(r"""
...     \times 2/3 { c'8 d' ~ d' } e' r
...     r e' \times 2/3 { d' ~ d' c' }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).components(abjad.Tuplet)
>>> result = result.leaves(tail=True, pitched=True)
>>> for item in result:
...     item
... 
Note("c'8")
Note("d'8")
Note("d'8")
Note("c'8")
>>> selector = abjad.select()
>>> selector = selector.components(abjad.Tuplet)
>>> selector = selector.leaves(tail=True, pitched=True)
>>> result = selector(staff)
>>> selector.print(result)
Note("c'8")
Note("d'8")
Note("d'8")
Note("c'8")
>>> selector.color(result)
>>> abjad.show(staff) 

Chord heads are the correct selection for arpeggios.

Selects chord heads in tuplets:

>>> staff = abjad.Staff(r"""
...     \times 2/3 { <c' e' g'>8 ~ <c' e' g'> d' } e' r
...     r <g d' fs'> \times 2/3 { e' <c' d'> ~ <c' d'> }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).components(abjad.Tuplet)
>>> result = result.leaves(abjad.Chord, head=True)
>>> for item in result:
...     item
... 
Chord("<c' e' g'>8")
Chord("<c' d'>8")
>>> selector = abjad.select().components(abjad.Tuplet)
>>> selector = selector.leaves(abjad.Chord, head=True)
>>> result = selector(staff)
>>> selector.print(result)
Chord("<c' e' g'>8")
Chord("<c' d'>8")
>>> selector.color(result)
>>> abjad.show(staff) 

Returns new selection (or expression).

logical_ties(grace_notes=False, nontrivial=None, pitched=None, reverse=False)

Selects logical ties (without grace notes).

Selects logical ties:

>>> staff = abjad.Staff("c'8 d' ~ { d' e' r f'~ } f' r")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).logical_ties()
>>> for item in result:
...     item
... 
LogicalTie([Note("c'8")])
LogicalTie([Note("d'8"), Note("d'8")])
LogicalTie([Note("e'8")])
LogicalTie([Rest('r8')])
LogicalTie([Note("f'8"), Note("f'8")])
LogicalTie([Rest('r8')])
>>> selector = abjad.select().logical_ties()
>>> result = selector(staff)
>>> selector.print(result)
LogicalTie([Note("c'8")])
LogicalTie([Note("d'8"), Note("d'8")])
LogicalTie([Note("e'8")])
LogicalTie([Rest('r8')])
LogicalTie([Note("f'8"), Note("f'8")])
LogicalTie([Rest('r8')])
>>> selector.color(result)
>>> abjad.show(staff) 

Selects pitched logical ties:

>>> staff = abjad.Staff("c'8 d' ~ { d' e' r f'~ } f' r")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).logical_ties(pitched=True)
>>> for item in result:
...     item
... 
LogicalTie([Note("c'8")])
LogicalTie([Note("d'8"), Note("d'8")])
LogicalTie([Note("e'8")])
LogicalTie([Note("f'8"), Note("f'8")])
>>> selector = abjad.select().logical_ties(pitched=True)
>>> result = selector(staff)
>>> selector.print(result)
LogicalTie([Note("c'8")])
LogicalTie([Note("d'8"), Note("d'8")])
LogicalTie([Note("e'8")])
LogicalTie([Note("f'8"), Note("f'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Selects pitched nontrivial logical ties:

>>> staff = abjad.Staff("c'8 d' ~ { d' e' r f'~ } f' r")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).logical_ties(
...     pitched=True,
...     nontrivial=True,
...     )
>>> for item in result:
...     item
... 
LogicalTie([Note("d'8"), Note("d'8")])
LogicalTie([Note("f'8"), Note("f'8")])
>>> selector = abjad.select().logical_ties(
...     pitched=True,
...     nontrivial=True,
...     )
>>> result = selector(staff)
>>> selector.print(result)
LogicalTie([Note("d'8"), Note("d'8")])
LogicalTie([Note("f'8"), Note("f'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Selects pitched logical ties (starting) in each tuplet:

>>> staff = abjad.Staff(r"""
...     \times 2/3 { c'8 d' e'  ~ } e' f' ~
...     \times 2/3 { f' g' a' ~ } a' b' ~
...     \times 2/3 { b' c'' d'' }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> getter = abjad.select().logical_ties(pitched=True)
>>> result = abjad.select(staff).components(abjad.Tuplet)
>>> result = result.map(getter)
>>> for item in result:
...     item
... 
Selection([LogicalTie([Note("c'8")]), LogicalTie([Note("d'8")]), LogicalTie([Note("e'8"), Note("e'8")])])
Selection([LogicalTie([Note("g'8")]), LogicalTie([Note("a'8"), Note("a'8")])])
Selection([LogicalTie([Note("c''8")]), LogicalTie([Note("d''8")])])
>>> selector = abjad.select().components(abjad.Tuplet)
>>> selector = selector.map(getter)
>>> result = selector(staff)
>>> selector.print(result)
Selection([LogicalTie([Note("c'8")]), LogicalTie([Note("d'8")]), LogicalTie([Note("e'8"), Note("e'8")])])
Selection([LogicalTie([Note("g'8")]), LogicalTie([Note("a'8"), Note("a'8")])])
Selection([LogicalTie([Note("c''8")]), LogicalTie([Note("d''8")])])
>>> selector.color(result)
>>> abjad.show(staff) 

Selects pitched logical ties (starting) in each of the last two tuplets:

>>> staff = abjad.Staff(r"""
...     \times 2/3 { c'8 d' e'  ~ } e' f' ~
...     \times 2/3 { f' g' a' ~ } a' b' ~
...     \times 2/3 { b' c'' d'' }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> getter = abjad.select().logical_ties(pitched=True)
>>> result = abjad.select(staff).components(abjad.Tuplet)[-2:]
>>> result = result.map(getter)
>>> for item in result:
...     item
... 
Selection([LogicalTie([Note("g'8")]), LogicalTie([Note("a'8"), Note("a'8")])])
Selection([LogicalTie([Note("c''8")]), LogicalTie([Note("d''8")])])
>>> selector = abjad.select().components(abjad.Tuplet)[-2:]
>>> selector = selector.map(getter)
>>> result = selector(staff)
>>> selector.print(result)
Selection([LogicalTie([Note("g'8")]), LogicalTie([Note("a'8"), Note("a'8")])])
Selection([LogicalTie([Note("c''8")]), LogicalTie([Note("d''8")])])
>>> selector.color(result)
>>> abjad.show(staff) 

Returns new selection (or expression).

map(expression=None)

Maps expression to items in selection.

Selects each tuplet as a separate selection:

>>> staff = abjad.Staff(r"""
...     \times 2/3 { r8 d' e' } f' r
...     r f' \times 2/3 { e' d' r8 }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).components(abjad.Tuplet)
>>> result = result.map(abjad.select())
>>> for item in result:
...     item
... 
Selection([Tuplet(Multiplier(2, 3), "r8 d'8 e'8")])
Selection([Tuplet(Multiplier(2, 3), "e'8 d'8 r8")])
>>> selector = abjad.select().components(abjad.Tuplet)
>>> selector = selector.map(abjad.select())
>>> result = selector(staff)
>>> selector.print(result)
Selection([Tuplet(Multiplier(2, 3), "r8 d'8 e'8")])
Selection([Tuplet(Multiplier(2, 3), "e'8 d'8 r8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Selects leaves in each component:

>>> staff = abjad.Staff(r"""
...     \times 2/3 { r8 d' e' } f' r
...     r f' \times 2/3 { e' d' r8 }
...     """)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = staff[:].map(abjad.select().leaves())
>>> for item in result:
...     item
... 
Selection([Rest('r8'), Note("d'8"), Note("e'8")])
Selection([Note("f'8")])
Selection([Rest('r8')])
Selection([Rest('r8')])
Selection([Note("f'8")])
Selection([Note("e'8"), Note("d'8"), Rest('r8')])
>>> selector = abjad.select().map(abjad.select().leaves())
>>> result = selector(staff[:])
>>> selector.print(result)
Selection([Rest('r8'), Note("d'8"), Note("e'8")])
Selection([Note("f'8")])
Selection([Rest('r8')])
Selection([Rest('r8')])
Selection([Note("f'8")])
Selection([Note("e'8"), Note("d'8"), Rest('r8')])
>>> selector.color(result)
>>> abjad.show(staff) 

Gets item 0 in each note run:

>>> string = r"c'4 \times 2/3 { d'8 r8 e'8 } r16 f'16 g'8 a'4"
>>> staff = abjad.Staff(string)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).runs()
>>> result = result.map(abjad.select()[0])
>>> for item in result:
...     item
... 
Note("c'4")
Note("e'8")
Note("f'16")
>>> selector = abjad.select().runs()
>>> selector = selector.map(abjad.select()[0])
>>> result = selector(staff)
>>> selector.print(result)
Note("c'4")
Note("e'8")
Note("f'16")
>>> selector.color(result)
>>> abjad.show(staff) 

Returns new selection (or expression).

nontrivial()

Filters selection by length greater than 1.

Selects nontrivial runs:

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).runs().nontrivial()
>>> for item in result:
...     item
... 
Selection([Note("d'8"), Note("e'8")])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector = abjad.select().runs().nontrivial()
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("d'8"), Note("e'8")])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector.color(result)
>>> abjad.show(staff) 
note(n)

Selects note n.

Selects note -1:

>>> tuplets = [
...     "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> result = abjad.select(staff).note(-1)
>>> result
Note("e'16")
>>> selector = abjad.select().note(-1)
>>> result = selector(staff)
>>> selector.print(result)
Note("e'16")
>>> selector.color(result)
>>> abjad.show(lilypond_file) 
notes()

Selects notes.

Selects notes:

>>> tuplets = [
...     "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> result = abjad.select(staff).notes()
>>> for item in result:
...     item
... 
Note("bf'16")
Note("c'16")
Note("bf'16")
Note("d'16")
Note("bf'16")
Note("e'16")
>>> selector = abjad.select().notes()
>>> result = selector(staff)
>>> selector.print(result)
Note("bf'16")
Note("c'16")
Note("bf'16")
Note("d'16")
Note("bf'16")
Note("e'16")
>>> selector.color(result)
>>> abjad.show(lilypond_file) 
partition_by_counts(counts, cyclic=False, enchain=False, fuse_overhang=False, nonempty=False, overhang=False)

Partitions selection by counts.

Partitions leaves into a single part of length 3; truncates overhang:

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.partition_by_counts(
...     [3],
...     cyclic=False,
...     overhang=False,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Rest('r8'), Note("d'8")])
>>> selector = abjad.select().leaves()
>>> selector = selector.partition_by_counts(
...     [3],
...     cyclic=False,
...     overhang=False,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Rest('r8'), Note("d'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Cyclically partitions leaves into parts of length 3; truncates overhang:

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves().partition_by_counts(
...     [3],
...     cyclic=True,
...     overhang=False,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Rest('r8'), Note("d'8")])
Selection([Note("e'8"), Rest('r8'), Note("f'8")])
>>> selector = abjad.select().leaves().partition_by_counts(
...     [3],
...     cyclic=True,
...     overhang=False,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Rest('r8'), Note("d'8")])
Selection([Note("e'8"), Rest('r8'), Note("f'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Cyclically partitions leaves into parts of length 3; returns overhang at end:

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves().partition_by_counts(
...     [3],
...     cyclic=True,
...     overhang=True,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Rest('r8'), Note("d'8")])
Selection([Note("e'8"), Rest('r8'), Note("f'8")])
Selection([Note("g'8"), Note("a'8")])
>>> selector = abjad.select().leaves().partition_by_counts(
...     [3],
...     cyclic=True,
...     overhang=True,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Rest('r8'), Note("d'8")])
Selection([Note("e'8"), Rest('r8'), Note("f'8")])
Selection([Note("g'8"), Note("a'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Cyclically partitions leaves into parts of length 3; fuses overhang to last part:

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves().partition_by_counts(
...     [3],
...     cyclic=True,
...     fuse_overhang=True,
...     overhang=True,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Rest('r8'), Note("d'8")])
Selection([Note("e'8"), Rest('r8'), Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector = abjad.select().leaves().partition_by_counts(
...     [3],
...     cyclic=True,
...     fuse_overhang=True,
...     overhang=True,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Rest('r8'), Note("d'8")])
Selection([Note("e'8"), Rest('r8'), Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Cyclically partitions leaves into parts of length 3; returns overhang at end:

>>> string = "c'8 r8 d'8 e'8 r8 f'8 g'8 a'8 b'8 r8 c''8"
>>> staff = abjad.Staff(string)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves().partition_by_counts(
...     [1, 2, 3],
...     cyclic=True,
...     overhang=True,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8")])
Selection([Rest('r8'), Note("d'8")])
Selection([Note("e'8"), Rest('r8'), Note("f'8")])
Selection([Note("g'8")])
Selection([Note("a'8"), Note("b'8")])
Selection([Rest('r8'), Note("c''8")])
>>> selector = abjad.select().leaves().partition_by_counts(
...     [1, 2, 3],
...     cyclic=True,
...     overhang=True,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8")])
Selection([Rest('r8'), Note("d'8")])
Selection([Note("e'8"), Rest('r8'), Note("f'8")])
Selection([Note("g'8")])
Selection([Note("a'8"), Note("b'8")])
Selection([Rest('r8'), Note("c''8")])
>>> selector.color(result, ['red', 'blue', 'cyan'])
>>> abjad.show(staff) 

Returns nested selection (or expression):

>>> type(result).__name__
'Selection'
partition_by_durations(durations, cyclic=False, fill=None, in_seconds=False, overhang=False)

Partitions selection by durations.

Cyclically partitions leaves into parts equal to exactly 3/8; returns overhang at end:

>>> staff = abjad.Staff(
...     "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |"
...     "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |"
...     )
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves().partition_by_durations(
...     [abjad.Duration(3, 8)],
...     cyclic=True,
...     fill=abjad.Exact,
...     in_seconds=False,
...     overhang=True,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("d'8"), Note("e'8")])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
Selection([Note("b'8"), Note("c''8")])
>>> selector = abjad.select().leaves().partition_by_durations(
...     [abjad.Duration(3, 8)],
...     cyclic=True,
...     fill=abjad.Exact,
...     in_seconds=False,
...     overhang=True,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Note("d'8"), Note("e'8")])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
Selection([Note("b'8"), Note("c''8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Partitions leaves into one part equal to exactly 3/8; truncates overhang:

>>> staff = abjad.Staff(
...     "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |"
...     "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |"
...     )
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.partition_by_durations(
...     [abjad.Duration(3, 8)],
...     cyclic=False,
...     fill=abjad.Exact,
...     in_seconds=False,
...     overhang=False,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("d'8"), Note("e'8")])
>>> selector = abjad.select().leaves()
>>> selector = selector.partition_by_durations(
...     [abjad.Duration(3, 8)],
...     cyclic=False,
...     fill=abjad.Exact,
...     in_seconds=False,
...     overhang=False,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Note("d'8"), Note("e'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Cyclically partitions leaves into parts equal to (or just less than) 3/16 and 1/16; returns overhang at end:

>>> staff = abjad.Staff(
...     "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |"
...     "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |"
...     )
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.partition_by_durations(
...     [abjad.Duration(3, 16), abjad.Duration(1, 16)],
...     cyclic=True,
...     fill=abjad.More,
...     in_seconds=False,
...     overhang=True,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("d'8")])
Selection([Note("e'8")])
Selection([Note("f'8"), Note("g'8")])
Selection([Note("a'8")])
Selection([Note("b'8"), Note("c''8")])
>>> selector = abjad.select().leaves()
>>> selector = selector.partition_by_durations(
...     [abjad.Duration(3, 16), abjad.Duration(1, 16)],
...     cyclic=True,
...     fill=abjad.More,
...     in_seconds=False,
...     overhang=True,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Note("d'8")])
Selection([Note("e'8")])
Selection([Note("f'8"), Note("g'8")])
Selection([Note("a'8")])
Selection([Note("b'8"), Note("c''8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Cyclically partitions leaves into parts equal to (or just less than) 3/16; truncates overhang:

>>> staff = abjad.Staff(
...     "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |"
...     "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |"
...     )
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.partition_by_durations(
...     [abjad.Duration(3, 16)],
...     cyclic=True,
...     fill=abjad.Less,
...     in_seconds=False,
...     overhang=False,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8")])
Selection([Note("d'8")])
Selection([Note("e'8")])
Selection([Note("f'8")])
Selection([Note("g'8")])
Selection([Note("a'8")])
Selection([Note("b'8")])
>>> selector = abjad.select().leaves()
>>> selector = selector.partition_by_durations(
...     [abjad.Duration(3, 16)],
...     cyclic=True,
...     fill=abjad.Less,
...     in_seconds=False,
...     overhang=False,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8")])
Selection([Note("d'8")])
Selection([Note("e'8")])
Selection([Note("f'8")])
Selection([Note("g'8")])
Selection([Note("a'8")])
Selection([Note("b'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Partitions leaves into a single part equal to (or just less than) 3/16; truncates overhang:

>>> staff = abjad.Staff(
...     "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |"
...     "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |"
...     )
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.partition_by_durations(
...     [abjad.Duration(3, 16)],
...     cyclic=False,
...     fill=abjad.Less,
...     in_seconds=False,
...     overhang=False,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8")])
>>> selector = abjad.select().leaves()
>>> selector = selector.partition_by_durations(
...     [abjad.Duration(3, 16)],
...     cyclic=False,
...     fill=abjad.Less,
...     in_seconds=False,
...     overhang=False,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Cyclically partitions leaves into parts equal to exactly 1.5 seconds; truncates overhang:

>>> staff = abjad.Staff(
...     "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |"
...     "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |"
...     )
>>> abjad.setting(staff).auto_beaming = False
>>> mark = abjad.MetronomeMark((1, 4), 60)
>>> leaf = abjad.inspect(staff).leaf(0)
>>> abjad.attach(mark, leaf, context='Staff')
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.partition_by_durations(
...     [1.5],
...     cyclic=True,
...     fill=abjad.Exact,
...     in_seconds=True,
...     overhang=False,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("d'8"), Note("e'8")])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector = abjad.select().leaves()
>>> selector = selector.partition_by_durations(
...     [1.5],
...     cyclic=True,
...     fill=abjad.Exact,
...     in_seconds=True,
...     overhang=False,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Note("d'8"), Note("e'8")])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Cyclically partitions leaves into parts equal to exactly 1.5 seconds; returns overhang at end:

>>> staff = abjad.Staff(
...     "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |"
...     "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |"
...     )
>>> abjad.setting(staff).auto_beaming = False
>>> mark = abjad.MetronomeMark((1, 4), 60)
>>> leaf = abjad.inspect(staff).leaf(0)
>>> abjad.attach(mark, leaf, context='Staff')
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.partition_by_durations(
...     [1.5],
...     cyclic=True,
...     fill=abjad.Exact,
...     in_seconds=True,
...     overhang=True,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("d'8"), Note("e'8")])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
Selection([Note("b'8"), Note("c''8")])
>>> selector = abjad.select().leaves()
>>> selector = selector.partition_by_durations(
...     [1.5],
...     cyclic=True,
...     fill=abjad.Exact,
...     in_seconds=True,
...     overhang=True,
...     )
>>> selector.print(result)
Selection([Note("c'8"), Note("d'8"), Note("e'8")])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
Selection([Note("b'8"), Note("c''8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Partitions leaves into a single part equal to exactly 1.5 seconds; truncates overhang:

>>> staff = abjad.Staff(
...     "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |"
...     "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |"
...     )
>>> abjad.setting(staff).auto_beaming = False
>>> mark = abjad.MetronomeMark((1, 4), 60)
>>> leaf = abjad.inspect(staff).leaf(0)
>>> abjad.attach(mark, leaf, context='Staff')
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.partition_by_durations(
...     [1.5],
...     cyclic=False,
...     fill=abjad.Exact,
...     in_seconds=True,
...     overhang=False,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("d'8"), Note("e'8")])
>>> selector = abjad.select().leaves()
>>> selector = selector.partition_by_durations(
...     [1.5],
...     cyclic=False,
...     fill=abjad.Exact,
...     in_seconds=True,
...     overhang=False,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Note("d'8"), Note("e'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Cyclically partitions leaves into parts equal to (or just less than) 0.75 seconds; truncates overhang:

>>> staff = abjad.Staff(
...     "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |"
...     "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |"
...     )
>>> abjad.setting(staff).auto_beaming = False
>>> mark = abjad.MetronomeMark((1, 4), 60)
>>> leaf = abjad.inspect(staff).leaf(0)
>>> abjad.attach(mark, leaf, context='Staff')
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.partition_by_durations(
...     [0.75],
...     cyclic=True,
...     fill=abjad.Less,
...     in_seconds=True,
...     overhang=False,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8")])
Selection([Note("d'8")])
Selection([Note("e'8")])
Selection([Note("f'8")])
Selection([Note("g'8")])
Selection([Note("a'8")])
Selection([Note("b'8")])
>>> selector = abjad.select().leaves()
>>> selector = selector.partition_by_durations(
...     [0.75],
...     cyclic=True,
...     fill=abjad.Less,
...     in_seconds=True,
...     overhang=False,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8")])
Selection([Note("d'8")])
Selection([Note("e'8")])
Selection([Note("f'8")])
Selection([Note("g'8")])
Selection([Note("a'8")])
Selection([Note("b'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Partitions leaves into one part equal to (or just less than) 0.75 seconds; truncates overhang:

>>> staff = abjad.Staff(
...     "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |"
...     "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |"
...     )
>>> abjad.setting(staff).auto_beaming = False
>>> mark = abjad.MetronomeMark((1, 4), 60)
>>> leaf = abjad.inspect(staff).leaf(0)
>>> abjad.attach(mark, leaf, context='Staff')
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.partition_by_durations(
...     [0.75],
...     cyclic=False,
...     fill=abjad.Less,
...     in_seconds=True,
...     overhang=False,
...     )
>>> for item in result:
...     item
... 
Selection([Note("c'8")])
>>> selector = abjad.select().leaves()
>>> selector = selector.partition_by_durations(
...     [0.75],
...     cyclic=False,
...     fill=abjad.Less,
...     in_seconds=True,
...     overhang=False,
...     )
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Interprets fill as Exact when fill is none.

Parts must equal durations exactly when fill is Exact.

Parts must be less than or equal to durations when fill is Less.

Parts must be greater or equal to durations when fill is More.

Reads durations cyclically when cyclic is true.

Reads component durations in seconds when in_seconds is true.

Returns remaining components at end in final part when overhang is true.

Returns nested selection (or expression):

>>> type(result).__name__
'Selection'
partition_by_ratio(ratio)

Partitions selection by ratio.

Partitions leaves by a ratio of 1:1:

>>> string = r"c'8 d' r \times 2/3 { e' r f' } g' a' r"
>>> staff = abjad.Staff(string)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.partition_by_ratio((1, 1))
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("d'8"), Rest('r8'), Note("e'8"), Rest('r8')])
Selection([Note("f'8"), Note("g'8"), Note("a'8"), Rest('r8')])
>>> selector = abjad.select().leaves()
>>> selector = selector.partition_by_ratio((1, 1))
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Note("d'8"), Rest('r8'), Note("e'8"), Rest('r8')])
Selection([Note("f'8"), Note("g'8"), Note("a'8"), Rest('r8')])
>>> selector.color(result)
>>> abjad.show(staff) 

Partitions leaves by a ratio of 1:1:1:

>>> string = r"c'8 d' r \times 2/3 { e' r f' } g' a' r"
>>> staff = abjad.Staff(string)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves()
>>> result = result.partition_by_ratio((1, 1, 1))
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Note("d'8"), Rest('r8')])
Selection([Note("e'8"), Rest('r8'), Note("f'8")])
Selection([Note("g'8"), Note("a'8"), Rest('r8')])
>>> selector = abjad.select().leaves()
>>> selector = selector.partition_by_ratio((1, 1, 1))
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Note("d'8"), Rest('r8')])
Selection([Note("e'8"), Rest('r8'), Note("f'8")])
Selection([Note("g'8"), Note("a'8"), Rest('r8')])
>>> selector.color(result, ['red', 'blue', 'cyan'])
>>> abjad.show(staff) 

Returns nested selection (or expression):

>>> type(result).__name__
'Selection'
rest(n)

Selects rest n.

Selects rest -1:

>>> tuplets = [
...     "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> result = abjad.select(staff).rest(-1)
>>> result
Rest('r16')
>>> selector = abjad.select().rest(-1)
>>> result = selector(staff)
>>> selector.print(result)
Rest('r16')
>>> selector.color(result)
>>> abjad.show(lilypond_file) 
rests()

Selects rests.

Selects rests:

>>> tuplets = [
...     "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> result = abjad.select(staff).rests()
>>> for item in result:
...     item
... 
Rest('r16')
Rest('r16')
Rest('r16')
>>> selector = abjad.select().rests()
>>> result = selector(staff)
>>> selector.print(result)
Rest('r16')
Rest('r16')
Rest('r16')
>>> selector.color(result)
>>> abjad.show(lilypond_file) 
run(n)

Selects run n.

Selects run -1:

>>> tuplets = [
...     "r16 c'16 c'16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 d'16 d'16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 e'16 e'16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> result = abjad.select(staff).run(-1)
>>> result
Selection([Note("e'16"), Note("e'16"), Note("e'16"), Chord("<fs' gs'>4"), Chord("<fs' gs'>16")])
>>> selector = abjad.select().run(-1)
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("e'16"), Note("e'16"), Note("e'16"), Chord("<fs' gs'>4"), Chord("<fs' gs'>16")])
>>> selector.color(result)
>>> abjad.show(lilypond_file) 
runs()

Selects runs.

Selects runs:

>>> tuplets = [
...     "r16 c'16 c'16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 d'16 d'16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 e'16 e'16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> result = abjad.select(staff).runs()
>>> for item in result:
...     item
... 
Selection([Note("c'16"), Note("c'16"), Note("c'16"), Chord("<d' e'>4"), Chord("<d' e'>16")])
Selection([Note("d'16"), Note("d'16"), Note("d'16"), Chord("<e' fs'>4"), Chord("<e' fs'>16")])
Selection([Note("e'16"), Note("e'16"), Note("e'16"), Chord("<fs' gs'>4"), Chord("<fs' gs'>16")])
>>> selector = abjad.select().runs()
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'16"), Note("c'16"), Note("c'16"), Chord("<d' e'>4"), Chord("<d' e'>16")])
Selection([Note("d'16"), Note("d'16"), Note("d'16"), Chord("<e' fs'>4"), Chord("<e' fs'>16")])
Selection([Note("e'16"), Note("e'16"), Note("e'16"), Chord("<fs' gs'>4"), Chord("<fs' gs'>16")])
>>> selector.color(result)
>>> abjad.show(lilypond_file) 
top()

Selects top components.

Selects top components (up from leaves):

>>> string = r"c'8 d' r \times 2/3 { e' r f' } g' a' r"
>>> staff = abjad.Staff(string)
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).leaves().top()
>>> for item in result:
...     item
... 
Note("c'8")
Note("d'8")
Rest('r8')
Tuplet(Multiplier(2, 3), "e'8 r8 f'8")
Note("g'8")
Note("a'8")
Rest('r8')
>>> selector = abjad.select().leaves().top()
>>> result = selector(staff)
>>> selector.print(result)
Note("c'8")
Note("d'8")
Rest('r8')
Tuplet(Multiplier(2, 3), "e'8 r8 f'8")
Note("g'8")
Note("a'8")
Rest('r8')
>>> selector.color(result)
>>> abjad.show(staff) 
tuplet(n)

Selects tuplet n.

Selects tuplet -1:

>>> tuplets = [
...     "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> result = abjad.select(staff).tuplet(-1)
>>> result
Tuplet(Multiplier(10, 9), "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16")
>>> selector = abjad.select().tuplet(-1)
>>> result = selector(staff)
>>> selector.print(result)
Tuplet(Multiplier(10, 9), "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16")
>>> selector.color(result)
>>> abjad.show(lilypond_file) 
tuplets()

Selects tuplets.

Selects tuplets:

>>> tuplets = [
...     "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16",
...     "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16",
...     "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16",
...     ]
>>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets)
>>> tuplets = [abjad.Tuplet(*_) for _ in tuplets]
>>> tuplets = [abjad.select(tuplets)]
>>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets)
>>> staff = lilypond_file[abjad.Staff]
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.override(staff).tuplet_bracket.direction = abjad.Up
>>> abjad.override(staff).tuplet_bracket.staff_padding = 3
>>> abjad.show(lilypond_file) 
>>> result = abjad.select(staff).tuplets()
>>> for item in result:
...     item
... 
Tuplet(Multiplier(10, 9), "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16")
Tuplet(Multiplier(8, 9), "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16")
Tuplet(Multiplier(10, 9), "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16")
>>> selector = abjad.select().tuplets()
>>> result = selector(staff)
>>> selector.print(result)
Tuplet(Multiplier(10, 9), "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16")
Tuplet(Multiplier(8, 9), "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16")
Tuplet(Multiplier(10, 9), "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16")
>>> selector.color(result)
>>> abjad.show(lilypond_file) 
with_next_leaf()

Extends selection with next leaf.

Selects runs (each with next leaf):

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).runs()
>>> result = result.map(abjad.select().with_next_leaf())
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Rest('r8')])
Selection([Note("d'8"), Note("e'8"), Rest('r8')])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector = abjad.select().runs()
>>> selector = selector.map(abjad.select().with_next_leaf())
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Rest('r8')])
Selection([Note("d'8"), Note("e'8"), Rest('r8')])
Selection([Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Selects pitched tails (each with next leaf):

>>> staff = abjad.Staff(r"c'8 r d' ~ d' e' ~ e' r8 f'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> getter = abjad.select()[-1].select().with_next_leaf()
>>> result = abjad.select(staff).logical_ties(pitched=True)
>>> result = result.map(getter)
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Rest('r8')])
Selection([Note("d'8"), Note("e'8")])
Selection([Note("e'8"), Rest('r8')])
Selection([Note("f'8")])
>>> selector = abjad.select().logical_ties(pitched=True)
>>> selector = selector.map(getter)
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Rest('r8')])
Selection([Note("d'8"), Note("e'8")])
Selection([Note("e'8"), Rest('r8')])
Selection([Note("f'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Pitched logical ties (each with next leaf) is the correct selection for single-pitch sustain pedal applications.

Selects pitched logical ties (each with next leaf):

>>> staff = abjad.Staff(r"c'8 r d' ~ d' e' ~ e' r8 f'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> result = abjad.select(staff).logical_ties(pitched=True)
>>> result = result.map(abjad.select().with_next_leaf())
>>> for item in result:
...     item
... 
Selection([Note("c'8"), Rest('r8')])
Selection([Note("d'8"), Note("d'8"), Note("e'8")])
Selection([Note("e'8"), Note("e'8"), Rest('r8')])
Selection([Note("f'8")])
>>> selector = abjad.select().logical_ties(pitched=True)
>>> selector = selector.map(abjad.select().with_next_leaf())
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8"), Rest('r8')])
Selection([Note("d'8"), Note("d'8"), Note("e'8")])
Selection([Note("e'8"), Note("e'8"), Rest('r8')])
Selection([Note("f'8")])
>>> for item in result:
...     abjad.attach(abjad.PianoPedalSpanner(), item)
... 
>>> selector.color(result)
>>> manager = abjad.override(staff).sustain_pedal_line_spanner
>>> manager.staff_padding = 6
>>> abjad.show(staff) 

Returns new selection (or expression).

with_previous_leaf()

Extends selection with previous leaf.

Selects runs (each with previous leaf):

>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> getter = abjad.select().with_previous_leaf()
>>> result = abjad.select(staff).runs().map(getter)
>>> for item in result:
...     item
... 
Selection([Note("c'8")])
Selection([Rest('r8'), Note("d'8"), Note("e'8")])
Selection([Rest('r8'), Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector = abjad.select().runs().map(getter)
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8")])
Selection([Rest('r8'), Note("d'8"), Note("e'8")])
Selection([Rest('r8'), Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Selects pitched heads (each with previous leaf):

>>> staff = abjad.Staff(r"c'8 r d' ~ d' e' ~ e' r8 f'8")
>>> abjad.setting(staff).auto_beaming = False
>>> abjad.show(staff) 
>>> getter = abjad.select()[0].select().with_previous_leaf()
>>> result = abjad.select(staff).logical_ties(pitched=True)
>>> result = result.map(getter)
>>> for item in result:
...     item
... 
Selection([Note("c'8")])
Selection([Rest('r8'), Note("d'8")])
Selection([Note("d'8"), Note("e'8")])
Selection([Rest('r8'), Note("f'8")])
>>> selector = abjad.select().logical_ties(pitched=True)
>>> selector = selector.map(getter)
>>> result = selector(staff)
>>> selector.print(result)
Selection([Note("c'8")])
Selection([Rest('r8'), Note("d'8")])
Selection([Note("d'8"), Note("e'8")])
Selection([Rest('r8'), Note("f'8")])
>>> selector.color(result)
>>> abjad.show(staff) 

Returns new selection (or expression).


Read-only properties

items

Gets items.

>>> abjad.Staff("c'4 d'4 e'4 f'4")[:].items
(Note("c'4"), Note("d'4"), Note("e'4"), Note("f'4"))

Returns tuple.