feat(circuit): allow DagCircuit.op_nodes to accept a set of instruction types#16472
feat(circuit): allow DagCircuit.op_nodes to accept a set of instruction types#16472legendaryashwin17-dev wants to merge 1 commit into
Conversation
…on types
Extend the op parameter of op_nodes to accept either a single Operation
type or a set/frozenset of types. When a set is provided, returns nodes
matching any of the given types, avoiding the need for multiple calls
and result concatenation.
Example usage:
dag.op_nodes({Measure, Reset}) # returns Measure + Reset nodes
dag.op_nodes(Measure) # still works (single type)
dag.op_nodes() # still works (all ops)
Fixes Qiskit#16458
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
|
|
|
Thanks for the contribution. There's some things missing here before we can properly review this as contribution:
|
Summary
Extends the op parameter of DagCircuit.op_nodes to accept either a single Operation type or a set/frozenset of types (#16458).
Changes
When a set is provided, op_nodes returns nodes matching any of the given types in a single pass, avoiding the need for multiple calls and result concatenation.
Before:
After:
Implementation
Testing
Fixes #16458