Use greedy_topological_sort to sort operations in musical scores - #1948
Use greedy_topological_sort to sort operations in musical scores#1948Acciaccatura wants to merge 13 commits into
greedy_topological_sort to sort operations in musical scores#1948Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the musical score drawing logic in qualtran/drawing/musical_score.py to use a greedy topological sort and adds a test verifying that the musical score aligns with the qubit count. However, a critical bug was identified where the logic for updating topological generations and incrementing seq_x is incorrectly indented outside of the main loop, leading to rendering issues and incorrect topological generation assignments. A detailed code suggestion was provided to fix the indentation and logic.
mainly, this actually sets topo_gen to a value but also better implements the desired logic for setting (and possibly later updating) topological generations. this also fixes some erroneous line indentations.
There was a problem hiding this comment.
Code Review
This pull request updates the musical score drawing logic to use a greedy topological sort and track the depth of each qubit line to compute topological generations. It also adds a test to verify that the musical score aligns with the expected qubit count. Feedback on these changes includes addressing a potential KeyError when looking up newly allocated lines in y_to_topo_gen and removing a leftover assert False debugging statement in the new test.
substitutes
nx.topological_generationsforgreedy_topological_sortwhen ordering operations in musical score layouts. additionally:output ends up looking like this (though it should be noted this PR leaves the original display logic intact and still does not make use of
topo_gen. i assume we would like to make use of that in a separate PR meant for cleaning up the musical scores?):fixes #1640