From 631d51b18c35d320e15fdf341ec08ca3f594231c Mon Sep 17 00:00:00 2001 From: Alon Grinberg Dana Date: Wed, 4 Dec 2024 14:20:18 +0200 Subject: [PATCH] Added numpy_to_list() to common --- t3/common.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/t3/common.py b/t3/common.py index d5c40628..af4b5b5e 100644 --- a/t3/common.py +++ b/t3/common.py @@ -3,6 +3,7 @@ """ import datetime +import numpy as np import os import re import string @@ -389,3 +390,19 @@ def remove_numeric_parentheses(input_string: str) -> str: """ result = re.sub(r'\(\d+\)$', '', input_string) return result + + +def numpy_to_list(data) -> list: + """ + A helper function to convert NumPy arrays to lists. + + Args: + data: The data to convert. + + Returns: + list: The converted data. + """ + if isinstance(data, np.ndarray): + return data.tolist() + return data +