Open tonmoy-b opened 2 months ago
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:
@Qiskit/terra-core
@kevinhartman
@mtreinish
Hi @mtreinish ,
I have made this PR to fix issue 12972: Add a method to compute gate counts per qubit
Kindly take a look and let me know if any changes should be made.
For a quick look, the new code works as below:
a = QuantumCircuit(3, 3)
a.h(0)
a.x(1)
a.h(1)
a.cx(1, 0)
b = a.count_ops_with_qubits()
assert b == [
("h", "Qubit(QuantumRegister(3, 'q'), 0)"),
("x", "Qubit(QuantumRegister(3, 'q'), 1)"),
("h", "Qubit(QuantumRegister(3, 'q'), 1)"),
("cx", "Qubit(QuantumRegister(3, 'q'), 1)"),
("cx", "Qubit(QuantumRegister(3, 'q'), 0)"),
]
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
crates/accelerate/src/two_qubit_decompose.rs | 1 | 90.82% | ||
crates/qasm2/src/lex.rs | 5 | 92.23% | ||
crates/qasm2/src/parse.rs | 12 | 97.15% | ||
<!-- | Total: | 18 | --> |
Totals | |
---|---|
Change from base Build 10598013395: | 0.008% |
Covered Lines: | 71661 |
Relevant Lines: | 80334 |
Hi @mtreinish ,
I have made the changes as recommended, kindly take a look.
Thanks and Regards, Tonmoy
Hi, I don't mean to be a nuisance but I would appreciate a review and suggestions for updates if needed. Thanks
Hi, I'd appreciate a review of this PR. I believe it is probably close to what's required at this point.
fixes #12972
Summary
Added function to tally operations in circuit with associated qubits fixes #12972
Details and comments
-Added function count_ops_with_qubits() in quantumcircuit.py, this returns the operations in the QuantumCircuit along with the qubits associated with those operations. -The abovementioned function uses the Rust function fn operations_with_qubits in circuit_data.rs -A test (test_count_ops_with_qubits()) has been added to file test/python/circuit/test_circuit_data.py -tox has been run -- no test failures reported -tox -eblack run to reformat files
[Yes ] I have added the tests to cover my changes. [Yes ] I have updated the documentation accordingly. [Yes ] I have read the CONTRIBUTING document.