summaryrefslogtreecommitdiff
path: root/lib/utils/string.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2023-02-27 16:05:52 +0100
committerGitHub <noreply@github.com>2023-02-27 16:05:52 +0100
commitec076315bb8b5f901670fee1c06db028242b21fd (patch)
tree17cd3413f48cad338d95452d2d0aac96aac44d01 /lib/utils/string.py
parented4aa55a733986436853e2ee7ad22f757b09fcb1 (diff)
Various lock stitch options (#2006)
Co-authored-by: Lex Neva
Diffstat (limited to 'lib/utils/string.py')
-rw-r--r--lib/utils/string.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/utils/string.py b/lib/utils/string.py
index e9204076..7ed99b77 100644
--- a/lib/utils/string.py
+++ b/lib/utils/string.py
@@ -7,7 +7,15 @@ def string_to_floats(string, delimiter=","):
"""Convert a string of delimiter-separated floats into a list of floats."""
floats = string.split(delimiter)
- return [float(num) for num in floats]
+ return [float(num) for num in floats if _is_float(num)]
+
+
+def _is_float(float_string):
+ try:
+ float(float_string)
+ return True
+ except ValueError:
+ return False
def remove_suffix(string, suffix):