diff --git a/miditoolkit/midi/containers.py b/miditoolkit/midi/containers.py index 19767b2..bf78592 100755 --- a/miditoolkit/midi/containers.py +++ b/miditoolkit/midi/containers.py @@ -295,16 +295,16 @@ def remove_invalid_notes(self, verbose: bool = True) -> None: def remove_notes_with_no_duration(self) -> None: """Removes (inplace) notes whose end time is before or at their start time.""" - for i in range(self.nb_notes - 1, -1, -1): + for i in range(self.num_notes - 1, -1, -1): if self.notes[i].start >= self.notes[i].end: del self.notes[i] @property - def nb_notes(self) -> int: + def num_notes(self) -> int: return len(self.notes) def __repr__(self): - return f"Instrument(program={self.program}, is_drum={self.is_drum}, name={self.name}) - {self.nb_notes} notes" + return f"Instrument(program={self.program}, is_drum={self.is_drum}, name={self.name}) - {self.num_notes} notes" def __eq__(self, other): # Here we check all tracks attributes except the name. diff --git a/tests/test_utils.py b/tests/test_utils.py index 467cae6..1ca2872 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -12,7 +12,7 @@ def test_remove_notes_with_no_duration(midi_path, tmp_path): # Load the MIDI file and removes the notes with durations <= 0 midi = MidiFile(midi_path) midi.instruments[0].remove_notes_with_no_duration() - nb_notes_before = midi.instruments[0].nb_notes + num_notes_before = midi.instruments[0].num_notes # Adding notes with durations <= 0, then reapply the method midi.instruments[0].notes.append(Note(50, 50, 100, 100)) @@ -20,5 +20,5 @@ def test_remove_notes_with_no_duration(midi_path, tmp_path): midi.instruments[0].remove_notes_with_no_duration() assert ( - midi.instruments[0].nb_notes == nb_notes_before + midi.instruments[0].num_notes == num_notes_before ), "The notes with duration <=0 were not removed by test_remove_notes_with_no_duration"