Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bug in repeat tests in romanText/translate.py; handles empty measures #1434

Merged
merged 4 commits into from
Sep 22, 2022

Conversation

malcolmsailor
Copy link
Contributor

While working on addressing #1412 I noticed that there was a syntax error in the romanText in testRepeats (my bad!). Each measure number was followed by a colon (i.e., "m1:" rather than "m1"). The first thing this PR fixes is removing those colons.

The colons caused the parser to insert a note in each measure. When I removed them, I discovered that the test was actually failing on measures that are empty except for forward/backward repeat bars. To fix this required two things:

  1. explicitly set the offset of backward repeat bars according to the time-signature length
  2. if a measure has 0 duration, explicitly set its duration according to the current time-signature

I also added a new test for the copying of empty measures.

@coveralls
Copy link

coveralls commented Sep 22, 2022

Coverage Status

Coverage increased (+0.002%) to 93.068% when pulling 192ed81 on malcolmsailor:remove-colons into b1ea58e on cuthbertLab:master.

@mscuthbert
Copy link
Member

Thanks!

Copy link
Member

@mscuthbert mscuthbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Realizing that the empty measures can't end empty (and duration on a stream should not be manipulated) -- proposed solution in comments.

music21/romanText/translate.py Outdated Show resolved Hide resolved
music21/romanText/translate.py Show resolved Hide resolved
appendMeasureToRepeatEndingsDict(self.lastMeasureToken,
mFill,
self.repeatEndings, i)
p.coreAppend(mFill)
self.lastMeasureNumber = measureToken.number[0] - 1
self.lastMeasureToken = measureToken

def fillMeasureFromPreviousRn(self, mFill: stream.Measure) -> None:
if self.previousRn is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine. but there's an easy refactor to avoid nesting.

if self.previousRn is None:
    return

Comment on lines +1701 to +1704
# mypy complains about the next line because
# RecursiveIterator.first() has t.Optional type, but we know
# it will not be None because we have just asserted that rn_iter
# has length 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's fine. :-)

@mscuthbert mscuthbert merged commit 6f8734a into cuthbertLab:master Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants