-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add label assigned check in SparsePauliOp #8101
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f2b09e1
add assign check
daimurat 0f37f94
Update qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py
daimurat 4d9db73
fix check condition
daimurat 74c7c39
update reno
Cryoris 82af8ed
update reno section header
Cryoris 4ddb629
Merge branch 'main' into issue_#7916
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 6 additions & 0 deletions
6
releasenotes/notes/add_check_from_sparse_list-97f13fde87c7bcb6.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,6 @@ | ||
--- | ||
upgrade: | ||
Cryoris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- | | ||
Added a check process and a flag which is used to check if the qubit designated from input Pauli list is already assigned (not I) | ||
to :func:`from_sparse_list` in the :class:`SparsePauliOp`. The flag is used if check is to be run. The default value is True. | ||
See `#7916 <https://github.com/Qiskit/qiskit-terra/issues/7916>`__. |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
I
should be checked too, otherwise it's unclear how we interpret using an index multiple times 🙂 Could you add that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Cryoris.
How about not to being allowed input
I
instead of checkingI
?I think there seems to be no use case that input
I
should be applied.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is true that there is no reason to pass
I
with sparse format, so I don't think we need to allowI
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's true, strictly speaking there's not reason to pass
I
. But it might be restrictive to explicitly forbid it because (1) if a user happens to have strings withI
in them they would have to clean the string, which can be cumbersome (maybe the string is automatically constructed) and (2) we would have to add a check whetherI
is included. I think it would be easier for both users and us if we just allow any Pauli string.We could of course clean the input strings and only store the non-
I
ones, that might be good though!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I feel that it is ok to not check
I
for the first version. Personally, I am concerned that it would complicate the implementation. As long as we make errors as long as the output is clearly strange (as issue pointed out), we don't have problems.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few ways to implement it which a not complicating the implementation I think 🙂 For example one of the following 2:
indices
contains duplicated (that might be even simpler than the current code 🙂)labels
withNone
and use the check that you currently have. Then at the end replace all leftNone
s with"I"
🙂There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both has extra computational cost, but I'd prefer 1 using
set
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I fixed the check condition. Could you review it?