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

Use hash of numeric value for bound parameter expressions #12488

Merged
merged 2 commits into from
Jun 11, 2024

Conversation

wshanks
Copy link
Contributor

@wshanks wshanks commented May 31, 2024

Summary

If a ParameterExpression has no unbound parameters, the underlying bound value can be hashed instead of the tuple that accounts for the symbolic expression. Doing this allows for the ParameterExpression to match the hash for the numeric value it compares equal to.

Details and comments

Closes #12487

If a `ParameterExpression` has no unbound parameters, the underlying
bound value can be hashed instead of the tuple that accounts for the
symbolic expression. Doing this allows for the `ParameterExpression` to
match the hash for the numeric value it compares equal to.

Closes Qiskit#12487
@wshanks wshanks requested a review from a team as a code owner May 31, 2024 20:55
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core

@coveralls
Copy link

coveralls commented May 31, 2024

Pull Request Test Coverage Report for Build 9406862530

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 1 of 2 (50.0%) changed or added relevant lines in 1 file are covered.
  • 60 unchanged lines in 5 files lost coverage.
  • Overall coverage decreased (-0.002%) to 89.579%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/circuit/parameterexpression.py 1 2 50.0%
Files with Coverage Reduction New Missed Lines %
qiskit/circuit/parameterexpression.py 4 96.54%
crates/qasm2/src/lex.rs 5 92.11%
qiskit/qasm2/parse.py 6 96.7%
crates/qasm2/src/parse.rs 12 97.15%
crates/circuit/src/circuit_data.rs 33 93.13%
Totals Coverage Status
Change from base Build 9318953704: -0.002%
Covered Lines: 62367
Relevant Lines: 69622

💛 - Coveralls

jakelishman
jakelishman previously approved these changes Jun 3, 2024
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

Thanks for finding this, Will. This looks right to me.

@jakelishman
Copy link
Member

Oh, actually, can we have a bugfix release note?

@jakelishman jakelishman added stable backport potential The bug might be minimal and/or import enough to be port to stable mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library Changelog: Bugfix Include in the "Fixed" section of the changelog labels Jun 3, 2024
@jakelishman
Copy link
Member

@Mergifyio backport stable/0.46

Copy link
Contributor

mergify bot commented Jun 3, 2024

backport stable/0.46

✅ Backports have been created

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

Thanks Will.

@jakelishman jakelishman added this pull request to the merge queue Jun 11, 2024
Merged via the queue into Qiskit:main with commit bc685d3 Jun 11, 2024
15 checks passed
mergify bot pushed a commit that referenced this pull request Jun 11, 2024
* Use hash of numeric value for bound parameter expressions

If a `ParameterExpression` has no unbound parameters, the underlying
bound value can be hashed instead of the tuple that accounts for the
symbolic expression. Doing this allows for the `ParameterExpression` to
match the hash for the numeric value it compares equal to.

Closes #12487

* Add release note

(cherry picked from commit bc685d3)
mergify bot pushed a commit that referenced this pull request Jun 11, 2024
* Use hash of numeric value for bound parameter expressions

If a `ParameterExpression` has no unbound parameters, the underlying
bound value can be hashed instead of the tuple that accounts for the
symbolic expression. Doing this allows for the `ParameterExpression` to
match the hash for the numeric value it compares equal to.

Closes #12487

* Add release note

(cherry picked from commit bc685d3)
github-merge-queue bot pushed a commit that referenced this pull request Jun 12, 2024
…12548)

* Use hash of numeric value for bound parameter expressions

If a `ParameterExpression` has no unbound parameters, the underlying
bound value can be hashed instead of the tuple that accounts for the
symbolic expression. Doing this allows for the `ParameterExpression` to
match the hash for the numeric value it compares equal to.

Closes #12487

* Add release note

(cherry picked from commit bc685d3)

Co-authored-by: Will Shanks <[email protected]>
Procatv pushed a commit to Procatv/qiskit-terra-catherines that referenced this pull request Aug 1, 2024
* Use hash of numeric value for bound parameter expressions

If a `ParameterExpression` has no unbound parameters, the underlying
bound value can be hashed instead of the tuple that accounts for the
symbolic expression. Doing this allows for the `ParameterExpression` to
match the hash for the numeric value it compares equal to.

Closes Qiskit#12487

* Add release note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bound ParameterExpressions do not match the hash of an equal object of a numeric type
4 participants