Adding a new argument to 'plot_state_qsphere' #5177
Closed
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.
Motivation
I ran into this situation where only some states were visible while visualizing the qsphere few days 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:
with
show_state_phases=True
Default:
New Argument:
Case 2: Tested for three-qubit circuit (clutter possibility is medium-high)
Default:
New Argument:
with
show_state_phases=True
Default:
New Argument:
P.S.: This is my first attempt with PR on Github.