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

Add QuantumCircuit.get_parameter to retrieve by name #11431

Merged
merged 4 commits into from
Jan 8, 2024

Conversation

jakelishman
Copy link
Member

@jakelishman jakelishman commented Dec 19, 2023

Summary

This allows Parameter instances to be retrieved from a circuit by string name. The interface is a mirror of the same functionality already added for run-time variables (get_var), but for the compile-time Parameter class. Similarly, a has_parameter method mirrors has_var.

Details and comments

Depends on #11428, which this PR currently includes. Now up to date.

@jakelishman jakelishman added Changelog: New Feature Include in the "Added" section of the changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library labels Dec 19, 2023
@jakelishman jakelishman added this to the 1.0.0 milestone Dec 19, 2023
@jakelishman jakelishman requested a review from a team as a code owner December 19, 2023 12:32
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented Dec 19, 2023

Pull Request Test Coverage Report for Build 7422369056

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 87.561%

Totals Coverage Status
Change from base Build 7416093664: -0.02%
Covered Lines: 59479
Relevant Lines: 67929

💛 - Coveralls

This allows `Parameter` instances to be retrieved from a circuit by
string name.  The interface is a mirror of the same functionality
already added for run-time variables (`get_var`), but for the
compile-time `Parameter` class.  Similarly, a `has_parameter` method
mirrors `has_var`.
@jakelishman
Copy link
Member Author

Now rebased and ready for review.

Copy link
Contributor

@Cryoris Cryoris left a comment

Choose a reason for hiding this comment

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

It will be very nice to have support for binding by parameter name, thanks! 🙂 I left some comments below.

qiskit/circuit/quantumcircuit.py Show resolved Hide resolved
qiskit/circuit/parametertable.py Show resolved Hide resolved
qiskit/circuit/parametertable.py Outdated Show resolved Hide resolved
qiskit/circuit/quantumcircuit.py Outdated Show resolved Hide resolved
qiskit/circuit/quantumcircuit.py Outdated Show resolved Hide resolved
jakelishman and others added 2 commits January 5, 2024 13:08
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
@Cryoris Cryoris added this pull request to the merge queue Jan 8, 2024
Merged via the queue into Qiskit:main with commit 3263355 Jan 8, 2024
13 checks passed
@jakelishman jakelishman deleted the parameter-by-name branch January 8, 2024 13:19
ShellyGarion pushed a commit to ShellyGarion/qiskit-terra that referenced this pull request Jan 18, 2024
* Add `QuantumCircuit.get_parameter` to retrieve by name

This allows `Parameter` instances to be retrieved from a circuit by
string name.  The interface is a mirror of the same functionality
already added for run-time variables (`get_var`), but for the
compile-time `Parameter` class.  Similarly, a `has_parameter` method
mirrors `has_var`.

* Update qiskit/circuit/parametertable.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Fix typos

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Fix blank space

---------

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants