Skip to content

Commit

Permalink
fix Note.__lt__
Browse files Browse the repository at this point in the history
  • Loading branch information
tandav committed Aug 3, 2024
1 parent a45f1e5 commit 9bd37f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/musiclib/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def __eq__(self, other: object) -> bool:

def __lt__(self, other: object) -> bool:
if isinstance(other, str):
return self.i <= _note_i[other]
return self.i < _note_i[other]
if isinstance(other, Note):
return self.i <= other.i
return self.i < other.i
raise TypeError

def __hash__(self) -> int:
Expand Down
7 changes: 7 additions & 0 deletions tests/note_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ def test_ordering(op, a, b):
assert op(a, b)


def test_ordering_lt():
assert not Note('C') < Note('C')
assert not Note('C') > Note('C')
assert Note('C') <= Note('C')
assert Note('C') >= Note('C')


def test_note_sub():
assert Note('C') - Note('C') == AbstractInterval(0)
assert Note('G') - Note('C') == AbstractInterval(7)
Expand Down

0 comments on commit 9bd37f9

Please sign in to comment.