From 8f383dfe12bbc9128e5dbacd5b365d6cac99f214 Mon Sep 17 00:00:00 2001 From: sammlapp Date: Thu, 2 May 2024 14:09:26 -0400 Subject: [PATCH] copy overlay_df resolves modifying original label df in overlay init #953 avoid modifying original overlay_df object passed to Overlay.__init__() --- opensoundscape/preprocess/actions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opensoundscape/preprocess/actions.py b/opensoundscape/preprocess/actions.py index 43ff0715..2e236481 100644 --- a/opensoundscape/preprocess/actions.py +++ b/opensoundscape/preprocess/actions.py @@ -8,6 +8,7 @@ See the preprocessor module and Preprocessing tutorial for details on how to use and create your own actions. """ + import random import warnings import numpy as np @@ -506,7 +507,7 @@ def __init__(self, is_augmentation=True, **kwargs): self.returns_labels = True - overlay_df = kwargs["overlay_df"] + overlay_df = kwargs["overlay_df"].copy() # copy to avoid modifying original overlay_df = overlay_df[~overlay_df.index.duplicated()] # remove duplicates # warn the user if using "different" as overlay_class