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

Fix qpy serialization of substitution of type ParameterExpression (backport #13890) #13943

Merged
merged 3 commits into from
Mar 3, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Mar 2, 2025

When substitution history ParameterExpression._qpy_replay is serialized, there was no branch for the case that the substituted value is of type ParameterExpression.

This commit fixes this oversight.

  • I have added the tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

Tests need to be added.

Closes #13879


This is an automatic backport of pull request #13890 done by [Mergify](https://mergify.com).

…13890)

* Fix qpy serialization of substitution of type ParameterExpression

When substitution history `ParameterExpression._qpy_replay` is serialized,
there was no branch for the case that the substituted value is of type
`ParameterExpression`.
This commit fixes this oversight.

* Fix deserializing qpy written by previous writing fix

* Added a branch for reading `ParameterExpression` in _qpy_replay

* Added a missing argument (version) in an existing call in code path that
  was previously untested

* Remove a bit of useless code introduced in last commit

* run black

* Add tests

* Revert renaming extra_symbols to extra_expressions

Reverting this to minimize changes in order to make the PR safer to
backport.

* Revert cleaning up logic in _encode_replay_subs

This was a good change. But not necessary for the bug fix, which is
the main point of this PR.

* Add qpy compat test

* Bind parameter when checking for equality

* Run black after merge in browser

---------

Co-authored-by: Luciano Bello <[email protected]>
(cherry picked from commit a6fa6f8)

# Conflicts:
#	test/qpy_compat/test_qpy.py
Copy link
Contributor Author

mergify bot commented Mar 2, 2025

Cherry-pick of a6fa6f8 has failed:

On branch mergify/bp/stable/1.4/pr-13890
Your branch is up to date with 'origin/stable/1.4'.

You are currently cherry-picking commit a6fa6f87d.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   qiskit/qpy/binary_io/value.py
	new file:   test/python/qpy/test_serialize_value_objects.py

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   test/qpy_compat/test_qpy.py

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify bot requested a review from a team as a code owner March 2, 2025 00:53
@mergify mergify bot added the conflicts used by mergify when there are conflicts in a port label Mar 2, 2025
@qiskit-bot
Copy link
Collaborator

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
  • @mtreinish
  • @nkanazawa1989

@github-actions github-actions bot added Changelog: Bugfix Include in the "Fixed" section of the changelog mod: qpy Related to QPY serialization labels Mar 2, 2025
@github-actions github-actions bot added this to the 2.0.0 milestone Mar 2, 2025
@coveralls
Copy link

coveralls commented Mar 2, 2025

Pull Request Test Coverage Report for Build 13632006440

Details

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • 22 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.006%) to 88.845%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.02%
crates/qasm2/src/lex.rs 9 90.98%
crates/qasm2/src/parse.rs 12 97.15%
Totals Coverage Status
Change from base Build 13530798718: -0.006%
Covered Lines: 79385
Relevant Lines: 89352

💛 - Coveralls

ElePT
ElePT previously approved these changes Mar 3, 2025
@ElePT ElePT modified the milestones: 2.0.0, 1.4.1 Mar 3, 2025
@ElePT ElePT removed the conflicts used by mergify when there are conflicts in a port label Mar 3, 2025
@ElePT ElePT added this pull request to the merge queue Mar 3, 2025
Merged via the queue into stable/1.4 with commit ff15ce4 Mar 3, 2025
19 checks passed
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: qpy Related to QPY serialization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants