From 5d1313f64b29af6ec5de2cd0e0f20ab54f8c5826 Mon Sep 17 00:00:00 2001 From: malcolmsailor Date: Wed, 10 Dec 2025 16:24:30 -0500 Subject: [PATCH] patch get_bars_ticks() --- src/miditok/utils/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/miditok/utils/utils.py b/src/miditok/utils/utils.py index 537adf26..aa7b6fe2 100644 --- a/src/miditok/utils/utils.py +++ b/src/miditok/utils/utils.py @@ -710,7 +710,11 @@ def get_bars_ticks(score: Score, only_notes_onsets: bool = False) -> list[int]: # Mock the last one to cover the last section in the loop below in all cases, as it # prevents the case in which the last time signature had an invalid numerator or # denominator (that would have been skipped in the while loop below). - time_sigs.append(TimeSignature(max_tick, *TIME_SIGNATURE)) + + # When only_notes_onsets is True, we add an extra tick because otherwise, when + # the last onset coincides with a start of a bar, it will be excluded because + # range() is exclusive of the endpoint. + time_sigs.append(TimeSignature(max_tick + int(only_notes_onsets), *TIME_SIGNATURE)) # Section from tick 0 to first time sig is 4/4 if first time sig time is not 0 if (