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

Update the type hints for QuantumCircuit.append #13617

Open
alexanderivrii opened this issue Jan 7, 2025 · 3 comments
Open

Update the type hints for QuantumCircuit.append #13617

alexanderivrii opened this issue Jan 7, 2025 · 3 comments
Assignees
Labels
documentation Something is not clear or an error documentation good first issue Good for newcomers
Milestone

Comments

@alexanderivrii
Copy link
Contributor

The QuantumCircuit.append method looks as follows

    def append(
        self,
        instruction: Operation | CircuitInstruction,
        qargs: Sequence[QubitSpecifier] | None = None,
        cargs: Sequence[ClbitSpecifier] | None = None,
        *,
        copy: bool = True,
    ) -> InstructionSet:

with the instruction being appended to a quantum circuit being of type Operation | CircuitInstruction.

In practice, however, we can add also anything that has a to_instruction method (see also this comment). It would be nice to reflect this functionality in the type hints and/or in the following docstring.

@alexanderivrii alexanderivrii added documentation Something is not clear or an error documentation good first issue Good for newcomers labels Jan 7, 2025
@alexanderivrii alexanderivrii added this to the 2.0.0 milestone Jan 7, 2025
@github-project-automation github-project-automation bot moved this to Tagged but unassigned in Contributor Monitoring Jan 7, 2025
@Ak-ash22
Copy link
Contributor

Hello... looks like this is issue is still free for grabs. May I take this up?

@alexanderivrii
Copy link
Contributor Author

Thank you! You are now assigned to the task.

@AngeloDanducci AngeloDanducci moved this from Tagged but unassigned to Assigned in Contributor Monitoring Jan 16, 2025
@Ak-ash22
Copy link
Contributor

Ak-ash22 commented Jan 20, 2025

Hello @alexanderivrii , I am thinking of modifying things the following way:

  1. type hints from instruction: Operation | CircuitInstruction to instruction: InstructionLike
  2. and docstring to include additionally in the , :class: ~.circuit would be converted into .circuit.Instruction. and include in the Args::class with .to_instruction() attribute.

What do you suggest about this? If you have a better way of putting things, kindly let me know.

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 good first issue Good for newcomers
Projects
Status: Assigned
Development

No branches or pull requests

2 participants