-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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]>
- Loading branch information
1 parent
b7d0a97
commit 0c03808
Showing
3 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
releasenotes/notes/bitarray-postselect-659b8f7801ccaa60.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
features_primitives: | ||
- | | ||
Added a new method :meth:`.BitArray.postselect` that returns all shots containing specified bit values. | ||
Example usage:: | ||
from qiskit.primitives.containers import BitArray | ||
ba = BitArray.from_counts({'110': 2, '100': 4, '000': 3}) | ||
print(ba.postselect([0,2], [0,1]).get_counts()) | ||
# {'110': 2, '100': 4} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters