-
Notifications
You must be signed in to change notification settings - Fork 406
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
Parse double flats in RomanText #1405
Conversation
>>> key.convertKeyStringToMusic21KeyString('bbb') | ||
'b--' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also a test for a different double-flat key than b, say 'Ebb' since that follows a completely different code path potentially than 'bbb'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think both cases follow the same path since the checks for B/b/Bb/bb only apply when the key has two or fewer characters. But I added such a test.
I wasn't sure what the right balance between comprehensiveness and readability was here since these are actually doctests (albeit ones that people who aren't actually developing music21 are probably unlikely to consult).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small changes to make the common case of Key of 'b' or 'B' work more quickly.
OK, done. Rather than checking for 'B' explicitly I just pass if the last character is anything other than 'b'; then we don't check all those other redundant conditions if e.g., the key is "F#" or "E", etc. |
It just occurred to me that this function will throw an exception if textString is the empty string. Should we handle that case or is the exception ok? |
Looks great! Thanks @malcolmsailor and for the last patch @jacobtylerwalls We can make empty string throw an exception later, but if so we should do it explicitly and not just with an |
Fixes #1390.
For the vast majority of cases (where there is just a single flat symbol) the regex on line 83 is overkill so we only run that if the preceding conditions don't match.