def test_lilypondparsertools_LilyPondParser__spanners__Trill_02(): r'''Swapped start and stop. ''' maker = abjad.NoteMaker() notes = maker(4 * [0], [(1, 4)]) target = abjad.Container(notes) trill = abjad.TrillSpanner() abjad.attach(trill, target[2:]) trill = abjad.TrillSpanner() abjad.attach(trill, target[:3]) assert format(target) == abjad.String.normalize( r''' { c'4 \startTrillSpan c'4 c'4 \stopTrillSpan \startTrillSpan c'4 \stopTrillSpan } ''' ) string = r"\relative c' { c \startTrillSpan c c \startTrillSpan \stopTrillSpan c \stopTrillSpan }" parser = abjad.lilypondparsertools.LilyPondParser() result = parser(string) assert format(target) == format(result) and target is not result
def test_lilypondparsertools_LilyPondParser__spanners__Trill_01(): r'''Successful trills, showing single leaf overlap. ''' maker = abjad.NoteMaker() notes = maker(4 * [0], [(1, 4)]) target = abjad.Container(notes) trill = abjad.TrillSpanner() abjad.attach(trill, target[2:]) trill = abjad.TrillSpanner() abjad.attach(trill, target[:3]) assert format(target) == abjad.String.normalize( r''' { c'4 \startTrillSpan c'4 c'4 \stopTrillSpan \startTrillSpan c'4 \stopTrillSpan } ''' ) parser = abjad.lilypondparsertools.LilyPondParser() result = parser(format(target)) assert format(target) == format(result) and target is not result
def test_spannertools_TrillSpanner___eq___01(): r'''Spanner is strict comparator. ''' spanner_1 = abjad.TrillSpanner() spanner_2 = abjad.TrillSpanner() assert not spanner_1 == spanner_2
def test_scoretools_Container__get_spanners_that_dominate_component_pair_02(): '''Get spanners in improper parentage. ''' container = abjad.Container("c'8 d'8 e'8 f'8") beam = abjad.Beam() abjad.attach(beam, container[:]) slur = abjad.Slur() abjad.attach(slur, container[:]) trill = abjad.TrillSpanner() abjad.attach(trill, container[:]) assert format(container) == abjad.String.normalize(r''' { c'8 [ ( \startTrillSpan d'8 e'8 f'8 ] ) \stopTrillSpan } ''') parentage = abjad.inspect(container).get_parentage(include_self=False) assert abjad.inspect(parentage).get_spanners() == []
def test_scoretools_Mutation_copy_02(): r'''Copy one measure and fracture spanners. ''' voice = abjad.Voice("abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 || 2/8 g'8 a'8 |") leaves = abjad.select(voice).leaves() slur = abjad.Slur() abjad.attach(slur, leaves) trill = abjad.TrillSpanner() abjad.attach(trill, leaves) beam = abjad.Beam() abjad.attach(beam, leaves) assert format(voice) == abjad.String.normalize(r''' \new Voice { { % measure \time 2/8 c'8 [ ( \startTrillSpan d'8 } % measure { % measure e'8 f'8 } % measure { % measure g'8 a'8 ] ) \stopTrillSpan } % measure } ''') result = abjad.mutate(voice[1:2]).copy() new = abjad.Voice(result) assert format(new) == abjad.String.normalize(r''' \new Voice { { % measure \time 2/8 e'8 [ ( \startTrillSpan f'8 ] ) \stopTrillSpan } % measure } ''') assert abjad.inspect(voice).is_well_formed() assert abjad.inspect(new).is_well_formed()
def test_scoretools_Mutation_copy_01(): r'''Deep copies components. Deep copies spanners that abjad.attach to client. Fractures spanners that abjad.attach to components not in client. Returns Python list of copied components. ''' voice = abjad.Voice("abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 || 2/8 g'8 a'8 |") leaves = abjad.select(voice).leaves() slur = abjad.Slur() abjad.attach(slur, leaves) trill = abjad.TrillSpanner() abjad.attach(trill, leaves) beam = abjad.Beam() abjad.attach(beam, leaves) assert format(voice) == abjad.String.normalize(r''' \new Voice { { % measure \time 2/8 c'8 [ ( \startTrillSpan d'8 } % measure { % measure e'8 f'8 } % measure { % measure g'8 a'8 ] ) \stopTrillSpan } % measure } ''') result = abjad.mutate(leaves[2:4]).copy() new = abjad.Voice(result) assert format(new) == abjad.String.normalize(r''' \new Voice { e'8 [ ( \startTrillSpan f'8 ] ) \stopTrillSpan } ''') assert abjad.inspect(voice).is_well_formed() assert abjad.inspect(new).is_well_formed()
def test_scoretools_Selection__get_dominant_spanners_01(): r'''Returns Python list of (spanner, index) pairs. Each (spanner, index) pair gives a spanner which dominates all components in list, together with the start-index at which spanner abjad.attaches to subelement of first component in list. Beam and trill dominate first container. ''' voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }") leaves = abjad.select(voice).leaves() beam = abjad.Beam() abjad.attach(beam, leaves[:4]) glissando = abjad.Glissando() abjad.attach(glissando, leaves[-4:]) trill = abjad.TrillSpanner() abjad.attach(trill, leaves) assert format(voice) == abjad.String.normalize(r''' \new Voice { { c'8 [ \startTrillSpan d'8 } { e'8 \glissando f'8 ] \glissando } { g'8 \glissando a'8 \stopTrillSpan } } ''') receipt = voice[:1]._get_dominant_spanners() assert len(receipt) == 2 assert (beam, 0) in receipt assert (trill, 0) in receipt
def test_scoretools_Selection__get_crossing_spanners_01(): r'''Returns unordered set of spanners crossing over the begin- or end-bounds of logical-voice-contiguous components. ''' voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 }") leaves = abjad.select(voice).leaves() slur = abjad.Slur() abjad.attach(slur, voice[1][:]) trill = abjad.TrillSpanner() abjad.attach(trill, leaves) assert format(voice) == abjad.String.normalize( r''' \new Voice { { c'8 \startTrillSpan d'8 } { e'8 ( f'8 ) \stopTrillSpan } } ''' ) spanners = abjad.select(voice)._get_crossing_spanners() assert spanners == [] spanners = abjad.select(leaves)._get_crossing_spanners() assert spanners == [] spanners = voice[:1]._get_crossing_spanners() assert len(spanners) == 1 assert trill in spanners spanners = abjad.select(leaves[:-1])._get_crossing_spanners() assert len(spanners) == 2 assert slur in spanners assert trill in spanners
def test_scoretools_Selection__get_dominant_spanners_07(): r'''Only trill dominates voice. ''' voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }") leaves = abjad.select(voice).leaves() beam = abjad.Beam() abjad.attach(beam, leaves[:4]) glissando = abjad.Glissando() abjad.attach(glissando, leaves[-4:]) trill = abjad.TrillSpanner() abjad.attach(trill, leaves) receipt = abjad.select(voice)._get_dominant_spanners() assert len(receipt) == 1 assert (trill, 0) in receipt
def test_scoretools_Selection__get_dominant_spanners_04(): r'''Beam and trill dominate first two containers. ''' voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }") leaves = abjad.select(voice).leaves() beam = abjad.Beam() abjad.attach(beam, leaves[:4]) glissando = abjad.Glissando() abjad.attach(glissando, leaves[-4:]) trill = abjad.TrillSpanner() abjad.attach(trill, leaves) receipt = voice[:2]._get_dominant_spanners() assert len(receipt) == 2 assert (beam, 0) in receipt assert (trill, 0) in receipt
def test_scoretools_Parentage__get_spanners_that_dominate_component_pair_03(): r'''Glissando and trill both dominate crack at voice[2:2]. ''' voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }") leaves = abjad.select(voice).leaves() beam = abjad.Beam() abjad.attach(beam, leaves[:4]) glissando = abjad.Glissando() abjad.attach(glissando, leaves[-4:]) trill = abjad.TrillSpanner() abjad.attach(trill, leaves) assert format(voice) == abjad.String.normalize(r''' \new Voice { { c'8 [ \startTrillSpan d'8 } { e'8 \glissando f'8 ] \glissando } { g'8 \glissando a'8 \stopTrillSpan } } ''') pair = (voice[1], voice[2]) receipt = voice._get_spanners_that_dominate_component_pair(*pair) assert len(receipt) == 2 assert (glissando, 2) in receipt assert (trill, 4) in receipt
def test_scoretools_Parentage__get_spanners_that_dominate_component_pair_01(): r'''Returns Python list of (spanner, index) pairs. Each spanner dominates an empty slice between components. No spanners dominate voice[0:0]. ''' voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }") leaves = abjad.select(voice).leaves() beam = abjad.Beam() abjad.attach(beam, leaves[:4]) glissando = abjad.Glissando() abjad.attach(glissando, leaves[-4:]) trill = abjad.TrillSpanner() abjad.attach(trill, leaves) assert format(voice) == abjad.String.normalize(r''' \new Voice { { c'8 [ \startTrillSpan d'8 } { e'8 \glissando f'8 ] \glissando } { g'8 \glissando a'8 \stopTrillSpan } } ''') receipt = voice._get_spanners_that_dominate_component_pair(None, voice[0]) assert len(receipt) == 0 assert receipt == []
def test_scoretools_Parentage__get_spanners_that_dominate_component_pair_04(): r'''No spanners dominate empty slice following voice. ''' voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }") leaves = abjad.select(voice).leaves() beam = abjad.Beam() abjad.attach(beam, leaves[:4]) glissando = abjad.Glissando() abjad.attach(glissando, leaves[-4:]) trill = abjad.TrillSpanner() abjad.attach(trill, leaves) assert format(voice) == abjad.String.normalize(r''' \new Voice { { c'8 [ \startTrillSpan d'8 } { e'8 \glissando f'8 ] \glissando } { g'8 \glissando a'8 \stopTrillSpan } } ''') pair = (voice[2], None) receipt = voice._get_spanners_that_dominate_component_pair(*pair) assert len(receipt) == 0 assert receipt == []
def test_spannertools_TrillSpanner_pitch_02(): r'''Works with no pitch. ''' staff = abjad.Staff("c'8 d'8 e'8 f'8") trill = abjad.TrillSpanner() abjad.attach(trill, staff[:2]) assert format(staff) == abjad.String.normalize(r''' \new Staff { c'8 \startTrillSpan d'8 \stopTrillSpan e'8 f'8 } ''') assert abjad.inspect(staff).is_well_formed()
def test_lilypondproxytools_LilyPondGrobNameManager___setattr___52(): r'''Override LilyPond TrillSpanner grob. ''' voice = abjad.Voice("c'8 d'8 e'8 f'8") trill = abjad.TrillSpanner() abjad.attach(trill, voice[:]) abjad.override(trill).trill_spanner.color = 'red' assert format(voice) == abjad.String.normalize(r''' \new Voice { \override TrillSpanner.color = #red c'8 \startTrillSpan d'8 e'8 \revert TrillSpanner.color f'8 \stopTrillSpan } ''')
def test_spannertools_TrillSpanner___init___01(): r'''Initialize empty trill spanner. ''' trill = abjad.TrillSpanner() assert isinstance(trill, abjad.TrillSpanner)