Skip to content

Conversation

raynelfss
Copy link
Contributor

Fixes #13996

Summary

We accidentaly removed the capability of indexing a BitLocation object. These commits add that functionality back!

Details and comments

In an oversight after #13860, when switching to use the pyo3 friendly BitLocations which is not an instance of namedtuple we did not extend it to include sequence methods __getitem__ and __len__, which results in breaking api changes.

The following commits add those methods to BitLocations and also labels the class correctly as a sequence in PyO3.

In an oversight after Qiskit#13860, when switching to use the pyo3 friendly `BitLocations` which is not an instance of `namedtuple` we did not extend it to include sequence methods `__getitem__` and `__len__`, which results in breaking api changes.

The following commits add those methods to `BitLocations` and also labels the class correctly as a `sequence` in PyO3.
@raynelfss raynelfss requested a review from a team as a code owner March 11, 2025 21:13
@qiskit-bot
Copy link
Collaborator

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

  • @Qiskit/terra-core

@raynelfss raynelfss added bug Something isn't working Changelog: None Do not include in changelog labels Mar 11, 2025
@raynelfss raynelfss added this to the 2.0.0 milestone Mar 11, 2025
@raynelfss raynelfss added the stable backport potential The bug might be minimal and/or import enough to be port to stable label Mar 11, 2025
@coveralls
Copy link

coveralls commented Mar 11, 2025

Pull Request Test Coverage Report for Build 13817269288

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

  • 17 of 18 (94.44%) changed or added relevant lines in 1 file are covered.
  • 69 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.02%) to 88.117%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/circuit/src/dag_circuit.rs 17 18 94.44%
Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/unitary_synthesis.rs 1 94.69%
crates/circuit/src/operations.rs 3 91.27%
crates/qasm2/src/lex.rs 4 92.73%
crates/accelerate/src/commutation_checker.rs 61 89.98%
Totals Coverage Status
Change from base Build 13796441242: -0.02%
Covered Lines: 72676
Relevant Lines: 82477

💛 - Coveralls

@raynelfss raynelfss requested a review from mtreinish March 12, 2025 15:44
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

This looks better to me, thanks for the updates. Just a few small inline comments

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
@raynelfss raynelfss added this pull request to the merge queue Mar 12, 2025
Merged via the queue into Qiskit:main with commit 3a80a81 Mar 12, 2025
20 checks passed
mergify bot pushed a commit that referenced this pull request Mar 12, 2025
)

* Add: `__getitem__` and other attributes to `BitLocations`
In an oversight after #13860, when switching to use the pyo3 friendly `BitLocations` which is not an instance of `namedtuple` we did not extend it to include sequence methods `__getitem__` and `__len__`, which results in breaking api changes.

The following commits add those methods to `BitLocations` and also labels the class correctly as a `sequence` in PyO3.

* Fix: Address review comments

* Fix: More formatting issues in tests

* Apply suggestions from code review

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

---------

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
(cherry picked from commit 3a80a81)
github-merge-queue bot pushed a commit that referenced this pull request Mar 12, 2025
) (#14008)

* Add: `__getitem__` and other attributes to `BitLocations`
In an oversight after #13860, when switching to use the pyo3 friendly `BitLocations` which is not an instance of `namedtuple` we did not extend it to include sequence methods `__getitem__` and `__len__`, which results in breaking api changes.

The following commits add those methods to `BitLocations` and also labels the class correctly as a `sequence` in PyO3.

* Fix: Address review comments

* Fix: More formatting issues in tests

* Apply suggestions from code review

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

---------

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
(cherry picked from commit 3a80a81)

Co-authored-by: Raynel Sanchez <87539502+raynelfss@users.noreply.github.com>
raynelfss added a commit to raynelfss/qiskit that referenced this pull request Mar 20, 2025
…kit#13997)

* Add: `__getitem__` and other attributes to `BitLocations`
In an oversight after Qiskit#13860, when switching to use the pyo3 friendly `BitLocations` which is not an instance of `namedtuple` we did not extend it to include sequence methods `__getitem__` and `__len__`, which results in breaking api changes.

The following commits add those methods to `BitLocations` and also labels the class correctly as a `sequence` in PyO3.

* Fix: Address review comments

* Fix: More formatting issues in tests

* Apply suggestions from code review

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

---------

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Changelog: None Do not include in changelog 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.

BitLocation is no longer indexable
4 participants