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

transpose key of RomanNumeral #1414

Merged
merged 3 commits into from
Sep 28, 2022

Conversation

malcolmsailor
Copy link
Contributor

Fixes the issue in #1413. I closely modeled RomanNumeral.transpose() on Harmony.transpose().

@coveralls
Copy link

coveralls commented Sep 8, 2022

Coverage Status

Coverage decreased (-0.06%) to 93.011% when pulling 4c71bab on malcolmsailor:rn-transpose into 00971f4 on cuthbertLab:master.

post.key = self.key.transpose(value, inPlace=False)
return post
else:
self.key = self.key.transpose(value, inPlace=False)
Copy link
Member

Choose a reason for hiding this comment

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

why couldn't this be self.key.transpose(value, inPlace=True) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I had in my initial commit (a40e41a) but I changed it based on the discussion in #1413 and your feedback at #1413 (comment).

Copy link
Member

Choose a reason for hiding this comment

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

ah okay -- yes, we solved the problem in RomanText but not elsewhere, my bad.

music21/roman.py Outdated
@@ -3089,6 +3091,28 @@ def _updatePitches(self):
f'_updatePitches() was unable to derive pitches from the figure: {self.figure!r}'
) # pragma: no cover

def transpose(self, value, *, inPlace=False) -> t.Optional[T]:
Copy link
Member

Choose a reason for hiding this comment

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

for this to work, self has to be annotated with T as well.

Copy link
Member

Choose a reason for hiding this comment

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

see Harmony L 2338

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, fixed, but mypy didn't seem to be complaining. The "x" seems to be because coverage decreased slightly. (Not quite sure why since both inPlace=True and inplace=False are tested in the RomanNumeral.transpose() doctest.)

@mscuthbert
Copy link
Member

I didn't see that this was ready because it was marked with an "x" -- reviewed now -- one fix needed to not get incorrect typing, one nice to have.

Consider looking at the paradigm in key.Key transpose where the two inPlace options are typed differently so that it's obvious to the typing system whether to expect a RN or None to be returned.

@malcolmsailor
Copy link
Contributor Author

mypy is failing now:

music21/audioSearch/__init__.py:529: error: Incompatible return value type (implicitly returns "None", expected "List[int]")
music21/interval.py:363: error: Incompatible return value type (implicitly returns "None", expected "Tuple[Literal['C', 'D', 'E', 'F', 'G', 'A', 'B'], int]")
music21/stream/iterator.py:796: error: A function returning TypeVar should receive at least one argument containing the same Typevar
Found 3 errors in 3 files (checked 259 source files)

I don't get these errors on my local machine; I just tried merging the current master into the branch and I still don't get them. So I'm not sure whether this PR is somehow introducing them?

@mscuthbert
Copy link
Member

mypy is failing now:

music21/audioSearch/__init__.py:529: error: Incompatible return value type (implicitly returns "None", expected "List[int]")
music21/interval.py:363: error: Incompatible return value type (implicitly returns "None", expected "Tuple[Literal['C', 'D', 'E', 'F', 'G', 'A', 'B'], int]")
music21/stream/iterator.py:796: error: A function returning TypeVar should receive at least one argument containing the same Typevar
Found 3 errors in 3 files (checked 259 source files)

I don't get these errors on my local machine; I just tried merging the current master into the branch and I still don't get them. So I'm not sure whether this PR is somehow introducing them?

They must have upgraded their version of mypy today and it now finds errors that it didn't before. Those aren't from your work, so we can go and merge and I'll squash them separately. THANKS!

@mscuthbert
Copy link
Member

oh, wait I turned on merge protection to prevent me from accidentally committing to master and I can't overrule this without some major tweaking (2-factor, etc.) so I'll get a separate fix in and then merge this. Sorry for the delay.

@mscuthbert
Copy link
Member

Closing and reopening to get a clean board.

@mscuthbert mscuthbert closed this Sep 28, 2022
@mscuthbert mscuthbert reopened this Sep 28, 2022
@mscuthbert mscuthbert merged commit 210ae11 into cuthbertLab:master Sep 28, 2022
@malcolmsailor malcolmsailor deleted the rn-transpose branch October 5, 2022 11:05
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