From 9bd37f9f317d307eaaa4227bb4f67827a151cc60 Mon Sep 17 00:00:00 2001 From: Alexander Rodionov Date: Sat, 3 Aug 2024 17:07:50 +0300 Subject: [PATCH] fix Note.__lt__ --- src/musiclib/note.py | 4 ++-- tests/note_test.py | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/musiclib/note.py b/src/musiclib/note.py index 3f8fa070..e89f13ec 100644 --- a/src/musiclib/note.py +++ b/src/musiclib/note.py @@ -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: diff --git a/tests/note_test.py b/tests/note_test.py index d4217091..353b62c3 100644 --- a/tests/note_test.py +++ b/tests/note_test.py @@ -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)