-
Notifications
You must be signed in to change notification settings - Fork 166
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
Python 3 and jazz updates #63
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ def __init__(self, name="C", octave=4, dynamics=None): | |
if dynamics is None: | ||
dynamics = {} | ||
if isinstance(name, six.string_types): | ||
|
||
self.set_note(name, octave, dynamics) | ||
elif hasattr(name, "name"): | ||
# Hardcopy Note object | ||
|
@@ -66,6 +67,7 @@ def __init__(self, name="C", octave=4, dynamics=None): | |
"Don't know what to do with name object: " "'%s'" % name | ||
) | ||
|
||
|
||
def set_channel(self, channel): | ||
self.channel = channel | ||
|
||
|
@@ -262,7 +264,7 @@ def from_shorthand(self, shorthand): | |
def __int__(self): | ||
"""Return the current octave multiplied by twelve and add | ||
notes.note_to_int to it. | ||
|
||
This means a C-0 returns 0, C-1 returns 12, etc. This method allows | ||
you to use int() on Notes. | ||
""" | ||
|
@@ -272,7 +274,7 @@ def __int__(self): | |
res += 1 | ||
elif n == "b": | ||
res -= 1 | ||
return res | ||
return int(res) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear why this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry also not sure why I added this - I'm guessing it was from a type bug but I'm afraid I can't recall |
||
|
||
def __lt__(self, other): | ||
"""Enable the comparing operators on Notes (>, <, \ ==, !=, >= and <=). | ||
|
@@ -293,6 +295,11 @@ def __eq__(self, other): | |
"""Compare Notes for equality by comparing their note values.""" | ||
if other is None: | ||
return False | ||
|
||
# added as was getting erros from play_Bar.set_key | ||
if type(other) == str: | ||
other = Note(other) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems to me we should not compare Notes and strings by implicit conversion, but instead raise a TypeError to uncover bugs. |
||
|
||
return int(self) == int(other) | ||
|
||
def __ne__(self, other): | ||
|
@@ -310,3 +317,4 @@ def __ge__(self, other): | |
def __repr__(self): | ||
"""Return a helpful representation for printing Note classes.""" | ||
return "'%s-%d'" % (self.name, self.octave) | ||
|
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.
It is unclear to me why you added
chords
andtemporal_notes
to this class. It seems they are not used elsewhere.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.
Not sure that I added this, maybe from a historic version of mingus? Guess it's fine to ignore