pathsim.utils.utils module
- pathsim.utils.utils.rel_error(a, b)[source]
Computes the relative error between two scalars.
It is robust to one of them being close to zero and falls back to the absolute error in this case.
Notes
this is actually faster then inlining the branching into the return statement
- pathsim.utils.utils.max_error(a, b)[source]
Computes the maximum absolute error / deviation between two iterables such as lists with numerical values. Returns a scalar value representing the maximum deviation.
Notes
this is actually faster then ‘max’ over a list comprehension
- pathsim.utils.utils.max_rel_error(a, b)[source]
Computes the maximum relative error between two iterables such as lists with numerical values.
It is robust to one of them being zero and falls back to the absolute error in this case.
It returns a scalar value representing the maximum relative error.
Notes
this is actually faster then ‘max’ over a list comprehension
- pathsim.utils.utils.max_error_dicts(a, b)[source]
Computes the maximum absolute error between two dictionaries with numerical values.
It returns a scalar value representing the maximum absolute error.
- pathsim.utils.utils.max_rel_error_dicts(a, b)[source]
Computes the maximum relative error between two dictionaries with numerical values.
It is robust to one of them being zero and falls back to the absolute error in this case.
It returns a scalar value representing the maximum relative error.
- pathsim.utils.utils.path_length_dfs(connections, starting_block, visited=None)[source]
Recursively compute the longest path (depth first search) in a directed graph from a starting node / block.
- Parameters:
connections (list[Connection]) – connections of the graph
starting_block (Block) – block to start dfs
visited (None, set) – set of already visited graph nodes (blocks)
- Returns:
length – length of path starting from ´starting_block´
- Return type: