Skip to content

Commit

Permalink
Fixed logical tie iteration edge-case.
Browse files Browse the repository at this point in the history
  • Loading branch information
josiah-wolf-oberholtzer committed May 31, 2016
1 parent 2f9c18a commit eef4184
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions abjad/tools/agenttools/IterationAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ def by_logical_tie(
prototype = scoretools.Leaf
if pitched:
prototype = (scoretools.Chord, scoretools.Note)
leaf, yielded = None, False
if not reverse:
for leaf in self.by_class(prototype):
yielded = False
Expand All @@ -681,7 +682,7 @@ def by_logical_tie(
if not nontrivial or not logical_tie.is_trivial:
yielded = True
yield logical_tie
if not yielded:
if leaf is not None and not yielded:
if tie_spanners and \
tuple(tie_spanners)[0]._is_my_first_leaf(leaf):
logical_tie = leaf._get_logical_tie()
Expand Down Expand Up @@ -711,7 +712,7 @@ def by_logical_tie(
if not nontrivial or not logical_tie.is_trivial:
yielded = True
yield logical_tie
if not yielded:
if leaf is not None and not yielded:
if tie_spanners and \
tuple(tie_spanners)[0]._is_my_last_leaf(leaf):
logical_tie = leaf._get_logical_tie()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,10 @@ def test_agenttools_IterationAgent_by_logical_tie_10():
assert len(logical_ties[1]) == 1
assert logical_ties[0][0] is staff[1][0]
assert logical_ties[1][0] is staff[1][1]


def test_agenttools_IterationAgent_by_logical_tie_11():
r'''No logical ties, but no errors either.'''
staff = Staff()
logical_ties = list(iterate(staff).by_logical_tie())
assert len(logical_ties) == 0

0 comments on commit eef4184

Please sign in to comment.