leaves_are_tieable¶
- auxjad.get.leaves_are_tieable(leaves: Union[abjad.select.Selection, collections.abc.Iterable[abjad.score.Component], collections.abc.Iterable[abjad.select.LogicalTie]], *, only_identical_pitches: bool = False) → bool[source]¶
Returns a
bool
representing whether or not two or more input leaves have any identical pitch(es) and thus can be tied. Input argument can be a singleabjad.Selection
with multiple leaves, or an iterable with elements of typeabjad.Leaf
or child classes.- Basic usage:
When one or more pitches of a leave is also present in the next one, the function returns
True
:>>> leaf1 = abjad.Note(r"c'4") >>> leaf2 = abjad.Note(r"c'4") >>> auxjad.get.leaves_are_tieable([leaf1, leaf2]) True
Note
Auxjad automatically adds this function as an extension function to
abjad.get
. It can thus be used from eitherauxjad.get
orabjad.get
namespaces. Therefore, the two lines below are equivalent:>>> leaf1 = abjad.Note(r"c'4") >>> leaf2 = abjad.Note(r"c'4") >>> auxjad.get.leaves_are_tieable([leaf1, leaf2]) True >>> abjad.get.leaves_are_tieable([leaf1, leaf2]) True
- Durations:
Durations do not affect the comparison.
>>> leaf1 = abjad.Note(r"c'2.") >>> leaf2 = abjad.Note(r"c'16") >>> leaf3 = abjad.Note(r"f'''16") >>> auxjad.get.leaves_are_tieable([leaf1, leaf2]) True >>> auxjad.get.leaves_are_tieable([leaf1, leaf3]) False >>> auxjad.get.leaves_are_tieable([leaf2, leaf3]) False
- Chords:
Handles chords.
>>> chord1 = abjad.Chord(r"<c' e' g'>4") >>> chord2 = abjad.Chord(r"<c' e' g'>16") >>> chord3 = abjad.Chord(r"<f''' fs'''>16") >>> auxjad.get.leaves_are_tieable([chord1, chord2]) True >>> auxjad.get.leaves_are_tieable([chord1, chord3]) False >>> auxjad.get.leaves_are_tieable([chord2, chord3]) False
only_identical_pitches
:By default, if any pitch in a leaf (be it either a note or chord) can be tied to the next leaf, the function returns
True
:>>> chord1 = abjad.Chord(r"<c' e' g'>4") >>> chord2 = abjad.Chord(r"<c' e' g' bf'>4") >>> note = abjad.Note(r"c'4") >>> auxjad.get.leaves_are_tieable([chord1, chord2]) True >>> auxjad.get.leaves_are_tieable([chord2, note]) True
Set the argument
only_identical_pitches
toTrue
so that the function only returnsTrue
for identical pitch collections:>>> chord1 = abjad.Chord(r"<c' e' g'>4") >>> chord2 = abjad.Chord(r"<c' e' g' bf'>4") >>> note = abjad.Note(r"c'4") >>> auxjad.get.leaves_are_tieable([chord1, chord2], ... only_identical_pitches=True, ... ) False >>> auxjad.get.leaves_are_tieable([chord2, note], ... only_identical_pitches=True, ... ) False >>> chord3 = abjad.Chord(r"<c' e' g' bf'>4") >>> chord4 = abjad.Chord(r"<c' e' g' bf'>4") >>> auxjad.get.leaves_are_tieable([chord3, chord4], ... only_identical_pitches=True, ... ) True
- Rests:
If rests are input, the return value is
False
. It also handles multi-measure rests.>>> leaf = abjad.Note(r"c'4") >>> rest = abjad.Rest(r"r4") >>> auxjad.get.leaves_are_tieable([leaf, rest]) False
- Parentage:
Leaves can also be part of
abjad.Container
’s or child classes.>>> container = abjad.Container(r"r4 <c' e'>4 <c' e'>2") >>> auxjad.get.leaves_are_tieable([container[1], container[2]]) True
- Multiple leaves:
It accepts more than two leaves and will return
True
if all leaves can be tied sequentially (i.e. leaf one to leaf two, leaf two to leaf three, etc.):>>> leaf1 = abjad.Note(r"c'4") >>> leaf2 = abjad.Note(r"c'4") >>> leaf3 = abjad.Note(r"c'2.") >>> auxjad.get.leaves_are_tieable([leaf1, leaf2, leaf3]) True
- Logical ties:
Accepts leaves as well as
abjad.LogicalTie
’s:>>> leaf = abjad.Note(r"c'2.") >>> staff = abjad.Staff(r"c'4 ~ c'16") >>> logical_tie = abjad.select(staff).logical_tie(0) >>> auxjad.get.leaves_are_tieable([leaf, logical_tie]) True
- Selections:
Accepts a single
abjad.Selection
as input and will returnTrue
if all leaves can be tied sequentially (i.e. leaf one to leaf two, leaf two to leaf three, etc.):>>> staff = abjad.Staff(r"c'2 c'4. c'8") >>> auxjad.get.leaves_are_tieable(staff[:]) True >>> staff = abjad.Staff(r"c'2 c'4. d'8") >>> auxjad.get.leaves_are_tieable(staff[:]) False