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

Adding a new argument to 'plot_state_qsphere' #5177

Closed
wants to merge 4 commits into from
Closed

Adding a new argument to 'plot_state_qsphere' #5177

wants to merge 4 commits into from

Conversation

pragyakatyayan
Copy link

@pragyakatyayan pragyakatyayan commented Oct 3, 2020

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 with show_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:

image

New Argument:

image

with show_state_phases=True

Default:

image

New Argument:

image


Case 2: Tested for three-qubit circuit (clutter possibility is medium-high)

Default:

image

New Argument:

image

with show_state_phases=True

Default:

image

New Argument:

image

P.S.: This is my first attempt with PR on Github.

The new argument shows all state labels when required for display purposes. `show_all_state_labels` is a boolean variable which is false by default and is optional. It should be set to true only if the user want to display all possible state labels for any particular circuit, otherwise could create clutter.
@CLAassistant
Copy link

CLAassistant commented Oct 3, 2020

CLA assistant check
All committers have signed the CLA.

@pragyakatyayan pragyakatyayan marked this pull request as draft October 5, 2020 06:39
This pull-request adds line nos. 781-796 in the original file state_visualisation.py
@pragyakatyayan pragyakatyayan marked this pull request as ready for review October 5, 2020 06:46
@pragyakatyayan pragyakatyayan marked this pull request as draft December 31, 2020 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants