-
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 a new argument to plot_state_qsphere (update to #5607) #6596
Open
pragyakatyayan
wants to merge
8
commits into
Qiskit:main
Choose a base branch
from
pragyakatyayan:addnewargument
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
pragyakatyayan
requested review from
nkanazawa1989,
nonhermitian and
a team
as code owners
June 17, 2021 15:26
HuangJunye
added
the
Community PR
PRs from contributors that are not 'members' of the Qiskit repo
label
Jun 21, 2022
Pull Request Test Coverage Report for Build 4981117588
💛 - Coveralls |
Pull Request Test Coverage Report for Build 6384990269
💛 - Coveralls |
Looks like you need to format your code using |
Instead of duplicating the logic for if not np.isclose(prob, 0) and show_state_labels: to if show_all_state_labels or (not np.isclose(prob, 0) and show_state_labels): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
UPDATE #2:
This is an attempt to resolve conflicts from PR #5607 (dated: 12 Jan 2021). It was under active review but the master branch got updates in the code with new releases. The PR suffered from some conflicts and failed in some tests. So, I have updated the code in this PR. My first attempt at this PR was in PR (#5177) on 3 October 2020.
Motivation
I ran into this situation where only some states were visible while visualizing the qsphere few months back and asked help here. It was then that @aasfaw motivated me to do something like this. Many thanks to him. See the conversation here.
Summary
The previous
show_state_labels
argument is meant to show labels for only weighted states. When used withshow_state_phases=True
the weighted states displayed their phase values. The states with 0 weights were not given the labels.The new 'optional' argument
show_all_state_labels
which is added with this PR shows all possible state labels when set to True. This Boolean variable which is false by default, aims at letting the end-user distinguish visually on the q-sphere between the states having zero weights and those having non-zero weights. The argument is kept optional to ensure that it is set to true only if the user wants to display all possible state labels for any particular circuit, the default view would show labels (and phases) for non-zero states only.The new argument works well with
show_state_phases=True
and shows phase values for all possible state labels.The test cases given below are performed for two circuits-one with 2 qubits and other with 3 qubits. Both the circuits were deliberately made to produce weights for half of the possible states, to notice the working of new argument for states with zero-weights. Snapshots show the default view and the new argument's output.
Details and comments
Case 1: Tested for two-qubit circuit (clutter possibility is low)
Default:
New Argument:
show_all_state_labels=True
with
show_state_phases=True
Default:
New Argument:
show_all_state_labels=True, show_state_phases=True
Case 2: Tested for three-qubit circuit (clutter possibility is medium-high)
Default:
New Argument:
with
show_state_phases=True
Default:
New Argument:
CAUTION: Users must note that this new argument might give you a cluttered output in case of qubits>3. That is why the argument's default setting is
False
. This argument must be set toTrue
if and only if user wants to see the positioning of all possible states on the qsphere.