string_to_tuple

glotaran.utils.sanitize.string_to_tuple(tuple_str: str, from_list=False) tuple[float, ...] | tuple[str, ...] | float | str[source]

Convert a string to a tuple if it matches a tuple pattern.

Parameters:
  • tuple_str (str) – A string representing some tuple to convert the numbers inside the string tuple are mapped to float

  • from_list (bool, optional) – only if true will a single number string be converted to float, otherwise returned as-is since it may represent a label, by default False

Returns:

Returns the tuple intended by the string

Return type:

tuple[float], tuple[str], float, str