def test_selectiontools_Selection__all_are_contiguous_components_in_same_parent_01(): r'''True for strictly contiguous leaves in voice. False for other time orderings of leaves in voice. ''' voice = Voice("c'8 d'8 e'8 f'8") assert Selection._all_are_contiguous_components_in_same_parent( voice.select_leaves()) assert not Selection._all_are_contiguous_components_in_same_parent( list(reversed(voice.select_leaves()))) components = [] components.extend(voice.select_leaves()[2:]) components.extend(voice.select_leaves()[:2]) assert not Selection._all_are_contiguous_components_in_same_parent( components) components = [] components.extend(voice.select_leaves()[3:4]) components.extend(voice.select_leaves()[0:1]) assert not Selection._all_are_contiguous_components_in_same_parent( components) components = [voice] components.extend(voice.select_leaves()) assert not Selection._all_are_contiguous_components_in_same_parent( components)
def test_selectiontools_Selection__all_are_contiguous_components_in_same_parent_01( ): r'''True for strictly contiguous leaves in voice. False for other time orderings of leaves in voice. ''' voice = Voice("c'8 d'8 e'8 f'8") assert Selection._all_are_contiguous_components_in_same_parent(voice[:]) assert not Selection._all_are_contiguous_components_in_same_parent( list(reversed(voice[:]))) components = [] components.extend(voice[2:]) components.extend(voice[:2]) assert not Selection._all_are_contiguous_components_in_same_parent( components) components = [] components.extend(voice[3:4]) components.extend(voice[:1]) assert not Selection._all_are_contiguous_components_in_same_parent( components) components = [voice] components.extend(voice[:]) assert not Selection._all_are_contiguous_components_in_same_parent( components)
def test_selectiontools_Selection__all_are_contiguous_components_in_same_parent_03(): r'''True for orphan leaves when allow_orphans is True. False for orphan leaves when allow_orphans is False. ''' notes = [Note("c'8"), Note("d'8"), Note("e'8"), Note("f'8")] assert Selection._all_are_contiguous_components_in_same_parent(notes) assert not Selection._all_are_contiguous_components_in_same_parent( notes, allow_orphans=False)
def test_selectiontools_Selection__all_are_contiguous_components_in_same_parent_03( ): r'''True for orphan leaves when allow_orphans is True. False for orphan leaves when allow_orphans is False. ''' notes = [Note("c'8"), Note("d'8"), Note("e'8"), Note("f'8")] assert Selection._all_are_contiguous_components_in_same_parent(notes) assert not Selection._all_are_contiguous_components_in_same_parent( notes, allow_orphans=False)
def test_selectiontools_Selection__all_are_contiguous_components_in_same_parent_04(): r'''Empty list returns True. ''' sequence = [] assert Selection._all_are_contiguous_components_in_same_parent(sequence)
def test_selectiontools_Selection__all_are_contiguous_components_in_same_parent_04( ): r'''Empty list returns True. ''' sequence = [] assert Selection._all_are_contiguous_components_in_same_parent(sequence)
def check_discontiguous_spanners(self): r'''There are now two different types of spanner. Most spanners demand that spanner components be logical-voice-contiguous. But a few special spanners (like Tempo) do not make such a demand. The check here consults the experimental `_contiguity_constraint`. Returns violators and total. ''' from abjad.tools.selectiontools import Selection violators = [] total, bad = 0, 0 for spanner in self.expr._get_descendants()._get_spanners(): if spanner._contiguity_constraint == 'logical voice': if not Selection._all_are_contiguous_components_in_same_logical_voice( spanner[:]): violators.append(spanner) total += 1 return violators, total
def test_selectiontools_Selection__all_are_contiguous_components_in_same_parent_02(): r'''True for unincorporated components when orphans allowed. False to unincorporated components when orphans not allowed. ''' voice = Voice(r''' { c'8 d'8 } { e'8 f'8 } ''') assert systemtools.TestManager.compare( voice, r''' \new Voice { { c'8 d'8 } { e'8 f'8 } } ''' ) assert Selection._all_are_contiguous_components_in_same_parent([voice]) assert not Selection._all_are_contiguous_components_in_same_parent( [voice], allow_orphans = False) assert Selection._all_are_contiguous_components_in_same_parent(voice[:]) assert Selection._all_are_contiguous_components_in_same_parent(voice[0][:]) assert Selection._all_are_contiguous_components_in_same_parent(voice[1][:]) assert not Selection._all_are_contiguous_components_in_same_parent( voice.select_leaves())
def test_selectiontools_Selection__all_are_contiguous_components_in_same_parent_02( ): r'''True for unincorporated components when orphans allowed. False to unincorporated components when orphans not allowed. ''' voice = Voice(r''' { c'8 d'8 } { e'8 f'8 } ''') assert systemtools.TestManager.compare( voice, r''' \new Voice { { c'8 d'8 } { e'8 f'8 } } ''') assert Selection._all_are_contiguous_components_in_same_parent([voice]) assert not Selection._all_are_contiguous_components_in_same_parent( [voice], allow_orphans=False) assert Selection._all_are_contiguous_components_in_same_parent(voice[:]) assert Selection._all_are_contiguous_components_in_same_parent(voice[0][:]) assert Selection._all_are_contiguous_components_in_same_parent(voice[1][:]) assert not Selection._all_are_contiguous_components_in_same_parent( voice.select_leaves())
def test_selectiontools_Selection__all_are_contiguous_components_in_same_parent_02( ): r'''True for unincorporated components when orphans allowed. False to unincorporated components when orphans not allowed. ''' voice = Voice(r''' { c'8 d'8 } { e'8 f'8 } ''') assert format(voice) == stringtools.normalize(r''' \new Voice { { c'8 d'8 } { e'8 f'8 } } ''') assert Selection._all_are_contiguous_components_in_same_parent([voice]) assert not Selection._all_are_contiguous_components_in_same_parent( [voice], allow_orphans=False) assert Selection._all_are_contiguous_components_in_same_parent(voice[:]) assert Selection._all_are_contiguous_components_in_same_parent(voice[0][:]) assert Selection._all_are_contiguous_components_in_same_parent(voice[1][:]) leaves = select(voice).by_leaf() assert not Selection._all_are_contiguous_components_in_same_parent(leaves)