Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve qiskit.circuit.QuantumCircuit page #13300

Open
wants to merge 54 commits into
base: main
Choose a base branch
from

Conversation

abbycross
Copy link
Collaborator

@abbycross abbycross commented Oct 8, 2024

Summary

Add code examples where useful, and copyedit if necessary; closes #13299
Add examples for

  • QuantumCircuit
  • data
  • global_phase
  • name
  • metadata
  • qregs
  • cregs
  • qubits
  • ancillas
  • clbits
  • layout
  • op_start_times
  • num_ancillas
  • num_clbits

Moving the rest to a new PR to break up the work in more manageable pieces!

@abbycross abbycross requested a review from a team as a code owner October 8, 2024 21:18
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@abbycross abbycross marked this pull request as draft October 8, 2024 21:18
@abbycross abbycross self-assigned this Oct 8, 2024
@abbycross abbycross added the documentation Something is not clear or an error documentation label Oct 8, 2024
@coveralls
Copy link

coveralls commented Oct 8, 2024

Pull Request Test Coverage Report for Build 12834300454

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 6 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.005%) to 88.958%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 6 92.23%
Totals Coverage Status
Change from base Build 12834092699: 0.005%
Covered Lines: 79440
Relevant Lines: 89301

💛 - Coveralls

Copy link
Member

@frankharkins frankharkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I have some minor suggestions but generally it looks great. I think this'll help a lot; seeing a concrete example of what the output looks like is often a big help for me.

qiskit/circuit/quantumcircuit.py Outdated Show resolved Hide resolved
Comment on lines 1217 to 1225
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit

q = QuantumRegister(2)
c = ClassicalRegister(2)
qc = QuantumCircuit(q, c)

qc.metadata = {'experiment_type': 'Bell state experiment'}

print(qc.metadata)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here as with .name. Also, do you know if this is needed since you've also added an example in metadata property? I'm not sure how it works

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure! I'll do it just for the sake of practicing rewriting the code to your suggestion...

Comment on lines 1363 to 1371
from qiskit.circuit.library import GroverOperator, Diagonal
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager

# Create circuit to test transpiler on
oracle = Diagonal([1] * 7 + [-1])
qc = QuantumCircuit(3)
qc.h([0, 1, 2])
qc = qc.compose(GroverOperator(oracle))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice example! Just a suggestion for a simpler circuit

Suggested change
from qiskit.circuit.library import GroverOperator, Diagonal
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
# Create circuit to test transpiler on
oracle = Diagonal([1] * 7 + [-1])
qc = QuantumCircuit(3)
qc.h([0, 1, 2])
qc = qc.compose(GroverOperator(oracle))
from qiskit.providers.fake_provider import GenericBackendV2
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
# Create circuit to test transpiler on
qc = QuantumCircuit(3)
qc.h([0, 1, 2])

qiskit/circuit/quantumcircuit.py Show resolved Hide resolved
qiskit/circuit/quantumcircuit.py Outdated Show resolved Hide resolved
qiskit/circuit/quantumcircuit.py Outdated Show resolved Hide resolved
qiskit/circuit/quantumcircuit.py Outdated Show resolved Hide resolved
qiskit/circuit/quantumcircuit.py Outdated Show resolved Hide resolved
@abbycross abbycross marked this pull request as ready for review January 16, 2025 18:35
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Something is not clear or an error documentation
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Improve qiskit/qiskit.circuit.QuantumCircuit page
5 participants