logical_selections
- auxjad.select.logical_selections(container: Container | Selection, *, include_multimeasure_rests: bool = True) Selection [source]
Takes an
abjad.Container
(or child class). Returns the logical selections of a container, that is the logical ties but with consecutive rests grouped together. Return value is in the form of aabjad.Selection
ofabjad.Selection
’s.- Basic usage:
Usage is similar to
abjad.select.logical_ties()
:>>> container = abjad.Container(r"c'4 ~ c'16 r8. r4.. d'16 ~ d'4") >>> logical_selections = auxjad.select.logical_selections(container) >>> for logical_selection in logical_selections: ... print(logical_selection.leaves()) Selection([Note("c'4"), Note("c'16")]) Selection([Rest('r8.'), Rest('r4..')]) Selection([Note("d'16"), Note("d'4")])
Note
Auxjad automatically adds this function as an extension function to
abjad.select
. It can thus be used from eitherauxjad.select
orabjad.select
namespaces. Therefore, the two lines below are equivalent:>>> container = abjad.Container(r"c'4 ~ c'16 r8. r4.. d'16 ~ d'4") >>> for logical_sel in auxjad.select.logical_selections(container): ... print(logical_sel.leaves()) Selection([Note("c'4"), Note("c'16")]) Selection([Rest('r8.'), Rest('r4..')]) Selection([Note("d'16"), Note("d'4")]) >>> for logical_sel in abjad.select.logical_selections(container): ... print(logical_sel.leaves()) Selection([Note("c'4"), Note("c'16")]) Selection([Rest('r8.'), Rest('r4..')]) Selection([Note("d'16"), Note("d'4")])
include_multimeasure_rests
:By default, this function groups multi-measure rests with the previous pitched leaf as a single logical selection.
>>> container = abjad.Container(r"c'2. ~ c'16 r8. R1 r4.. d'16 ~ d'2.") >>> logical_selections = auxjad.select.logical_selections(container) >>> for logical_selection in logical_selections: ... print(logical_selection.leaves()) Selection([Note("c'2."), Note("c'16")]) Selection([Rest('r8.'), MultimeasureRest('R1'), Rest('r4..')]) Selection([Note("d'16"), Note("d'2.")])
To treat multi-measure rests as their own logical selections, set
include_multimeasure_rests
toFalse
(default value isTrue
).>>> container = abjad.Container(r"c'2. ~ c'16 r8. R1 r4.. d'16 ~ d'2.") >>> logical_selections = auxjad.select.logical_selections( ... container, ... include_multimeasure_rests=False, ... ) >>> for logical_selection in logical_selections: ... print(logical_selection.leaves()) Selection([Note("c'2."), Note("c'16")]) Selection([Rest('r8.')]) Selection([MultimeasureRest('R1')]) Selection([Rest('r4..')]) Selection([Note("d'16"), Note("d'2.")])