Skip to content

Commit

Permalink
Added numpy_to_list() to common
Browse files Browse the repository at this point in the history
  • Loading branch information
alongd committed Dec 4, 2024
1 parent 9741fa1 commit 631d51b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions t3/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import datetime
import numpy as np
import os
import re
import string
Expand Down Expand Up @@ -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

0 comments on commit 631d51b

Please sign in to comment.