agglovar.util.str ================= .. py:module:: agglovar.util.str .. autoapi-nested-parse:: String utility functions. Functions --------- .. autoapisummary:: agglovar.util.str.collision_rename agglovar.util.str.collision_rename_all Module Contents --------------- .. py:function:: collision_rename(var_name: str, separator: Optional[str] = '.', *args: collections.abc.Container[str]) -> str Rename a variable to avoid collisions with existing values. Adds "_n" to a variable name where "n" is the lowest integer that does not collide with an existing name. If `var_name` does not collide, it is returned unmodified. :param var_name: Variable name. :param separator: Separator to use between the variable name and the counter. If None, defaults to ".". :param args: One or more containers to search for matches. :return: Renamed string. .. py:function:: collision_rename_all(var_names: collections.abc.Iterable[str], separator: Optional[str] = '.', *args: collections.abc.Container[str]) -> collections.abc.Iterator[str] Iterate through a list of names and deduplicate. :param var_names: Iterator of names. :param separator: Separator to use between the variable name and the counter. If None, defaults to ".". :param args: One or more containers to search for matches. :return: An iterator of deduplicated names.