pyrc.tools.functions#

add_leading_underscore(string: str = '') str#

Adds a leading underscore if not already existing and string is not None or empty.

Parameters:

string (str) – The string to check.

Returns:

Checked string.

Return type:

str

check_type(nodes, type1, type2) bool#
contains_symbol(expr: float | int | ndarray | number | Any) bool#

Check whether any sympy symbol appears in an expression, array, or scalar.

Parameters:

expr (float | int | np.ndarray | np.number | Any) – Expression, numpy array, list, scalar, or np.nan to check.

Returns:

True if any sympy symbol is found anywhere in expr.

Return type:

bool

fill_none(list1, list2)#
get_nested_attribute(obj, attribute_path: str)#

Get nested attribute value from object using dot notation.

Parameters:
  • obj (object) – Object to get attribute from

  • attribute_path (str) – Dot-separated attribute path (e.g., ‘material.name’)

Returns:

Value of the attribute

Return type:

Any

is_set(value)#

Returns True if the value is already set (by value or symbol) and False if it is np.nan.

Parameters:

value (any) – The value to check.

Returns:

True if the resistance value is already set and False if it is np.nan.

Return type:

bool

return_type(nodes: list, type1, check_value: list | Any = None)#
save_as_tex(filename, latex_str)#
subtract_seconds_from_string(date_string: str, seconds: int | float) str#
sympy_matrix_to_latex(matrix)#

Return a LaTeX representation of a sympy expression.

Parameters:

matrix (sympy.Matrix) – Expression or matrix to convert to LaTeX.

Returns:

LaTeX representation of expr.

Return type:

str

sympy_sparse_matrix_to_latex(M, filename, fontsize='20pt')#
sympy_to_tex(matrix, file)#