From d3b4353729ff864d1375367d6d135eac8099137b Mon Sep 17 00:00:00 2001 From: pstrepetov Date: Fri, 14 Feb 2025 20:30:45 +0300 Subject: [PATCH 1/2] added new parameter augment_copy to the augment_score function --- src/miditok/data_augmentation/data_augmentation.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/miditok/data_augmentation/data_augmentation.py b/src/miditok/data_augmentation/data_augmentation.py index 7d40f46a..0636c14a 100644 --- a/src/miditok/data_augmentation/data_augmentation.py +++ b/src/miditok/data_augmentation/data_augmentation.py @@ -257,6 +257,7 @@ def augment_score( velocity_range: tuple[int, int] = (1, 127), duration_in_ticks: bool = False, min_duration: int | float = 0.03125, + augment_copy: bool = True ) -> Score: r""" Augment a Score object by shifting its pitch, velocity and/or duration values. @@ -284,9 +285,12 @@ def augment_score( :param min_duration: minimum duration limit to apply if ``duration_offset`` is negative. If ``duration_in_ticks`` is ``True``, it must be given in ticks, otherwise in beats as a float or integer. (default: ``0.03125``) + :param augment_copy: if given True, a copy of the input ``symusic.Score`` object is + augmented and returned. If False, the input ``symusic.Score`` object is modified + in-place. (default: ``True``) :return: the augmented ``symusic.Score`` object. """ - score_aug = score.copy() + score_aug = score.copy() if augment_copy else score # score_aug = score.copy(deep=True) if pitch_offset != 0: From 435eb92e20b36c85b6962aee9eaa3d69ae79c4a4 Mon Sep 17 00:00:00 2001 From: pstrepetov Date: Fri, 14 Feb 2025 21:13:13 +0300 Subject: [PATCH 2/2] fixed linter warning --- src/miditok/data_augmentation/data_augmentation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miditok/data_augmentation/data_augmentation.py b/src/miditok/data_augmentation/data_augmentation.py index 0636c14a..051ae3dd 100644 --- a/src/miditok/data_augmentation/data_augmentation.py +++ b/src/miditok/data_augmentation/data_augmentation.py @@ -257,7 +257,7 @@ def augment_score( velocity_range: tuple[int, int] = (1, 127), duration_in_ticks: bool = False, min_duration: int | float = 0.03125, - augment_copy: bool = True + augment_copy: bool = True, ) -> Score: r""" Augment a Score object by shifting its pitch, velocity and/or duration values.