Skip to content

Fix pickle and repr for Duration. (backport #14174) #14193

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

Merged
merged 3 commits into from
Apr 8, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Apr 8, 2025

Summary

Adds missing Python pickle support for the new Duration type added in Qiskit 2.0.

Details and comments

To get this working, I needed to manually register the PyO3 generated Duration_xx Python classes at the module level, since pickle looks for them during deserialization. I'm not sure if there's a better way, but I'm open to suggestions if you can think of something cleaner. Pickle doesn't have explicit support in PyO3, so we're lucky to have any working solution here.

While fixing this, I also noticed that __repr__ was defined inside an impl block that wasn't decorated with #[pymethods], meaning it wasn't actually being used before. That's fixed here too.

Fixes #14169


This is an automatic backport of pull request #14174 done by Mergify.

@mergify mergify bot requested a review from a team as a code owner April 8, 2025 00:13
@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

@github-actions github-actions bot added Changelog: Bugfix Include in the "Fixed" section of the changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library labels Apr 8, 2025
@github-actions github-actions bot added this to the 2.0.1 milestone Apr 8, 2025
@coveralls
Copy link

coveralls commented Apr 8, 2025

Pull Request Test Coverage Report for Build 14330294605

Details

  • 21 of 26 (80.77%) changed or added relevant lines in 2 files are covered.
  • 23 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.02%) to 88.088%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/circuit/src/lib.rs 15 20 75.0%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.23%
crates/qasm2/src/lex.rs 4 91.73%
crates/qasm2/src/parse.rs 18 96.68%
Totals Coverage Status
Change from base Build 14316915198: -0.02%
Covered Lines: 72872
Relevant Lines: 82726

💛 - Coveralls

@ElePT ElePT enabled auto-merge April 8, 2025 09:52
@ElePT ElePT added this pull request to the merge queue Apr 8, 2025
Merged via the queue into stable/2.0 with commit 511ecbf Apr 8, 2025
26 checks passed
@mtreinish mtreinish deleted the mergify/bp/stable/2.0/pr-14174 branch April 29, 2025 23:17
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants