2021-03-12 04:17:19 +00:00
|
|
|
# Authors: see git history
|
|
|
|
#
|
|
|
|
# Copyright (c) 2010 Authors
|
|
|
|
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
|
|
|
|
|
2018-11-15 01:23:06 +00:00
|
|
|
def string_to_floats(string, delimiter=","):
|
|
|
|
"""Convert a string of delimiter-separated floats into a list of floats."""
|
|
|
|
|
|
|
|
floats = string.split(delimiter)
|
2023-02-27 15:05:52 +00:00
|
|
|
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
|
2023-01-18 02:44:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
def remove_suffix(string, suffix):
|
|
|
|
if string.endswith(suffix):
|
|
|
|
return string[:-len(suffix)]
|
|
|
|
else:
|
|
|
|
return string
|