Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{
c'8
[
\glissando
{
e'8
\glissando
}
f'8
]
}
"""
)
assert abjad.inspect(voice).wellformed()
assert abjad.inspect(leaf).wellformed()
assert format(staff) == abjad.String.normalize(
r"""
\new Staff
{
\set Staff.pedalSustainStyle = #'mixed
c'8
\unaCorda
c'8
c'8
c'8
\treCorde
}
"""
)
assert abjad.inspect(staff).wellformed()
voice_1[1] = voice_2[1]
assert format(voice_1) == abjad.String.normalize(
r"""
\new Voice
{
c'8
[
g'8
e'8
]
}
"""
), print(format(voice_1))
assert abjad.inspect(voice_1).wellformed()
assert format(voice_2) == abjad.String.normalize(
r"""
\new Voice
{
f'8
[
a'8
]
}
"""
), print(format(voice_2))
assert abjad.inspect(voice_2).wellformed()
def test_GraceContainer_parentage_02():
"""
Grace containers bound to leaf do have parent.
"""
note = abjad.Note(1, (1, 4))
grace_container = abjad.GraceContainer()
abjad.attach(grace_container, note)
grace_container = abjad.inspect(note).grace_container()
assert isinstance(grace_container, abjad.GraceContainer)
assert grace_container._main_leaf is note
assert grace_container._main_leaf is note
def test_LogicalTie__preprolated_duration_01():
staff = abjad.Staff("c' ~ c'16")
assert abjad.inspect(
staff[0]
).logical_tie()._get_preprolated_duration() == abjad.Duration(5, 16)
def test_Inspection_timespan_18():
"""
Offsets works with nested voices.
"""
staff = abjad.Staff(
[abjad.Voice("c'8 d'8 e'8 f'8"), abjad.Voice("c'8 d'8 e'8 f'8")]
)
for i, voice in enumerate(staff):
start_offset = abjad.inspect(voice).timespan().start_offset
assert start_offset == i * abjad.Offset(4, 8)
def _head_filter_subresult(result, head):
import abjad
result_ = []
for item in result:
if isinstance(item, abjad.Component):
logical_tie = abjad.inspect(item).get_logical_tie()
if head == (item is logical_tie.head):
result_.append(item)
else:
pass
elif isinstance(item, abjad.Selection):
if not all(isinstance(_, abjad.Component) for _ in item):
raise NotImplementedError(item)
selection = []
for component in item:
logical_tie = abjad.inspect(component).get_logical_tie()
if head == logical_tie.head:
selection.append(item)
else:
pass
selection = abjad.select(selection)
result_.append(selection)
return
tuplets = list(abjad.iterate(selections).components(abjad.Tuplet))
if divisions is None:
divisions = len(tuplets) * [None]
assert len(selections) == len(divisions)
assert len(tuplets) == len(divisions)
denominator = self.denominator
if isinstance(denominator, tuple):
denominator = abjad.Duration(denominator)
for tuplet, division in zip(tuplets, divisions):
if denominator == 'divisions':
tuplet.denominator = division.numerator
elif isinstance(denominator, abjad.Duration):
unit_duration = denominator
assert unit_duration.numerator == 1
duration = abjad.inspect(tuplet).get_duration()
denominator_ = unit_duration.denominator
nonreduced_fraction = duration.with_denominator(denominator_)
tuplet.denominator = nonreduced_fraction.numerator
elif abjad.mathtools.is_positive_integer(denominator):
tuplet.denominator = denominator
else:
message = f'invalid preferred denominator: {denominator!r}.'
raise Exception(message)
if music_specifier != silent_specifier:
continue
divisions = [
_ for _ in phrase
if isinstance(_[0], abjad.MultimeasureRest)
]
iterator = itertools.groupby(divisions, division_to_meter)
for meter, grouped_divisions in iterator:
grouped_divisions = list(grouped_divisions)
count = len(grouped_divisions)
if count == 1:
continue
for division in grouped_divisions[1:]:
phrase.remove(division)
rest = grouped_divisions[0][0]
multiplier = abjad.inspect(rest).get_indicator(
abjad.Multiplier)
abjad.detach(multiplier, rest)
multiplier = multiplier * count
abjad.attach(multiplier, rest)
def logical_tie_to_phrase(logical_tie):
import consort
parentage = abjad.inspect(logical_tie.head).get_parentage()
prototype = consort.MusicSpecifier
for parent in parentage:
if abjad.inspect(parent).has_indicator(prototype):
return parent