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

Bitarray postselect (backport #12693) #12836

Merged
merged 1 commit into from
Jul 29, 2024
Merged

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jul 29, 2024

Summary

Add method BitArray.postselect(), per issue #12688 .

[edit July 22, 2024: deleting outdated, distracting details from this description. See linked issue and the method docstring for more information.]


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

* define BitArray.postselect()

* add test for BitArray.postselect()

* lint

* remove redundant docstring text

* Update qiskit/primitives/containers/bit_array.py

Co-authored-by: Ian Hincks <[email protected]>

* docstring ticks (BitArray.postselect())

Co-authored-by: Ian Hincks <[email protected]>

* Simpler tests for BitArray.postselect

* lint

* add release note

* check postselect() arg lengths match

* fix postselect tests

- fix bugs with checking that ValueError is raised.
- addtionally run all tests on a "flat" data input

* lint

* Fix type-hint

We immediately check the lengths of these args, so they should be Sequences, not Iterables.

* remove spurious print()

* lint

* lint

* use bitwise operations for faster postselect

- Also added support for negative indices
- Also updated tests

* remove spurious print()

* end final line of release note

* try to fix docstring formatting

* fix bitarray test assertion

Co-authored-by: Takashi Imamichi <[email protected]>

* disallow postselect positional kwarg

Co-authored-by: Takashi Imamichi <[email protected]>

* fix numpy dtype args

* Simpler kwarg: "assume_unique"

* lint (line too long)

* simplification: remove assume_unique kwarg

* improve misleading comment

* raise IndexError if indices out of range

- Change ValueError to IndexError.
- Add check for out-of-range negative indices.
- Simplify use of mod
- Update test conditions (include checks for off-by-one errors)

* lint

* add negative-contradiction test

* Update docstring with IndexErrors

* lint

* change slice_bits error from ValueError to IndexError

* update slice_bits test to use IndexError

* change ValueError to IndexError in slice_shots

also update tests for this error

* update error type in slice_shots docstring

* Revert ValueError to IndexError changes

Reverting these changes as they will instead be made in a separate PR.

This reverts commit 8f32178.

Revert "update error type in slice_shots docstring"

This reverts commit 50545ef.

Revert "change ValueError to IndexError in slice_shots"

This reverts commit c4becd9.

Revert "update slice_bits test to use IndexError"

This reverts commit c2b0039.

* fix docstring formatting

Co-authored-by: Takashi Imamichi <[email protected]>

* allow selection to be int instead of bool

* In tests, give selection as type int

* lint

* add example to release note

* fix typo in test case

* add check of test

Co-authored-by: Takashi Imamichi <[email protected]>

* lint

---------

Co-authored-by: Ian Hincks <[email protected]>
Co-authored-by: Takashi Imamichi <[email protected]>
(cherry picked from commit 0c03808)
@mergify mergify bot requested review from a team as code owners July 29, 2024 10:44
@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
  • @ajavadia
  • @levbishop
  • @t-imamichi

@github-actions github-actions bot added Changelog: New Feature Include in the "Added" section of the changelog mod: primitives Related to the Primitives module labels Jul 29, 2024
@github-actions github-actions bot added this to the 1.2.0 milestone Jul 29, 2024
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10142810143

Details

  • 30 of 30 (100.0%) changed or added relevant lines in 1 file are covered.
  • 12 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.008%) to 89.947%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 6 91.86%
crates/qasm2/src/parse.rs 6 97.15%
Totals Coverage Status
Change from base Build 10118826632: -0.008%
Covered Lines: 66198
Relevant Lines: 73597

💛 - Coveralls

@ElePT ElePT enabled auto-merge July 29, 2024 11:16
@ElePT ElePT added this pull request to the merge queue Jul 29, 2024
Merged via the queue into stable/1.2 with commit bc45606 Jul 29, 2024
16 of 18 checks passed
@mergify mergify bot deleted the mergify/bp/stable/1.2/pr-12693 branch July 29, 2024 13:11
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: primitives Related to the Primitives module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants