npu.utils.str_utils
Classes
|
- class npu.utils.str_utils.StrUtils
- Author:
Alberto M. Esmoris Pena
Class with util static methods to work with strings.
- static to_numpy_expr(expr)
Receive an evaluable expression and replace any call to a standard math function to use numpy aliased as np instead.
- Parameters:
expr (str) – The expression to be numpyfied.
- Returns:
The numpyfied expression.
- static csv_header_from_names(names, sep=',')
Build a string representing a header for a CSV file. The header string contains the names of the attributes separated by the given separator.
- Parameters:
names (list of str) – The names of the attributes in the CSV.
sep (str) – The separator for the names of the attributes.
- Returns:
The header represented as a string.
- Return type:
str
- static csv_line_from_values(vals, sep=',')
Build a string representing a line of the body for a CSV file. The body string contains the values of the attributes separated by the given separator.
- Parameters:
vals (list of str) – The values of the attributes in the CSV.
sep (str) – The separator for the values of the attributes.
- Returns:
The line of the body represented as a string.
- Return type:
str
- static remove_leading_whitespace(s)
Remove the leading whitespaces to the left from a given string. Leading whitespaces are characters like ‘ ‘, ‘n’, ‘t’, ‘r’, etc.
- Parameters:
s (str) – The string whose leading whitespaces at the right extreme must be eliminated.
- Returns:
The string obtained after removing leading whitespaces from the input string.
- Return type:
str
- static remove_trailing_whitespaces(s)
Remove the trailing whitespaces to the right from a given string. Trailing whitespaces are characters like ‘ ‘, ‘n’, ‘t’, ‘r’, etc.
- Parameters:
s (str) – The string whose trailing whitespaces at the right extreme must be eliminated.
- Returns:
The string obtained after removing trailing whitespaces from the input string.
- Return type:
str