question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

small improvement to DAGCircuit.replace_block_with_op()

See original GitHub issue

What should we add?

Short version:

  • Add the line return new_node to the end of DAGCircuit.replace_block_with_op().

Details: DAGCircuit.replace_block_with_op(block, op, ...) internally creates a new_node containing op, and replaces the block of DAG nodes by this new_node.

I think replace_block_with_op() should return new_node. (Currently there is no return statement). This change would be in line with the behavior of DAGCircuit.substitute_node(), which does return its internal new_node. Otherwise, the user does not know the node_id or even the name of the new node, so finding the new node for further manipulations is difficult. (All I can think of is to look along one of the wires for the one node in the new DAG that wasn’t in the old DAG… obviously this is cumbersome.) Since the function already has new_node available internally, seems like we may as well return it.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
aeddins-ibmcommented, Sep 27, 2022

Thanks @enavarro51 , that would be great! (Sorry @jakelishman , I kept intending to come back to this but never found the time)

0reactions
jakelishmancommented, Sep 27, 2022

No worries at all - there’s no rush from our side!

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found