Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rasa/shared/core/training_data/visualization.py (#12544)
* refactor: rasa/shared/core/training_data/visualization.py In the refactored version, In function(_remove_auxiliary_nodes), I've replaced the conversion of graph.predecessors(i) into a list with the direct usage of the generator. Additionally, I've introduced the predecessors_seen set to efficiently keep track of seen predecessors. When a duplicated predecessor is found, we can remove the node and break out of the inner loop. This optimization reduces the time complexity of checking for duplicated nodes to approximately O((TMP_NODE_ID - special_node_idx) + out_degree(node)). * add: unit test for _remove_auxiliary_nodes() * add: test cases of _remove_auxiliary_nodes() In this commit, I have implemented example test cases to test method: _remove_auxiliary_nodes in @pytest.mark.parametrize. Also,fixed the import error of networkx. * refactor: blank/long lines in function: test_remove_auxiliary_nodes * remove: break statement after removing node In this version, I have removed break statement from the loop so it can remove all the predecessors nodes which are in predecessors_seen without breaking the loop. * fix: black formatting issue
- Loading branch information