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

Support for circuit.draw(initial_state=False) #4068

Merged
merged 31 commits into from Apr 6, 2020

Conversation

1ucian0
Copy link
Member

@1ucian0 1ucian0 commented Apr 2, 2020

This PR add support for the parameter initial_value in the drawers.

circuit = QuantumCircuit(2)
circuit.measure_all()
circuit.draw()
            ░ ┌─┐
      q_0: ─░─┤M├───
            ░ └╥┘┌─┐
      q_1: ─░──╫─┤M├
            ░  ║ └╥┘
measure_0: ════╩══╬═
                  ║
measure_1: ═══════╩═
circuit.draw(initial_value=True)
              ░ ┌─┐
     q_0: |0>─░─┤M├───
              ░ └╥┘┌─┐
     q_1: |0>─░──╫─┤M├
              ░  ║ └╥┘
measure_0: 0 ════╩══╬═
                    ║
measure_1: 0 ═══════╩═

Because the default is False, this PR changes the previous behavior (initial values were shown before).

This is a draft because the following drawers are pending:

  • Text
  • MPL (already default behavior)
  • Latex

@1ucian0 1ucian0 added the Changelog: API Change Include in the "Changed" section of the changelog label Apr 2, 2020
@1ucian0 1ucian0 changed the title Support for circuit.draw(initial_value=). Default is False Support for circuit.draw(initial_value=False) Apr 2, 2020
@1ucian0 1ucian0 marked this pull request as ready for review April 2, 2020 22:40
@ajavadia
Copy link
Member

ajavadia commented Apr 3, 2020

Thanks for quickly doing this. Can you call it initial_state as that is more accurate for a qubit.

@1ucian0
Copy link
Member Author

1ucian0 commented Apr 3, 2020

It also applies to classical bits. Does the word "state" proper there?

@ajavadia
Copy link
Member

ajavadia commented Apr 3, 2020

yeah i think so. but I would not call |+> a value for example.

@1ucian0 1ucian0 changed the title Support for circuit.draw(initial_value=False) Support for circuit.draw(initial_state=False) Apr 3, 2020
@1ucian0
Copy link
Member Author

1ucian0 commented Apr 3, 2020

yeah i think so. but I would not call |+> a value for example.

done!

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't reviewed the code yet, just left some inline comments about the release notes so far. The indention or line length might be off (it's very hard to retain whitespace in the github ui), but that can easily be fixed

1ucian0 and others added 3 commits April 3, 2020 13:48
…44.yaml

Co-Authored-By: Matthew Treinish <mtreinish@kortar.org>
…44.yaml

Co-Authored-By: Matthew Treinish <mtreinish@kortar.org>
…44.yaml

Co-Authored-By: Matthew Treinish <mtreinish@kortar.org>
@1ucian0 1ucian0 added this to the 0.13 milestone Apr 3, 2020
@kdk kdk added the automerge label Apr 6, 2020
@mergify mergify bot merged commit c614eec into Qiskit:master Apr 6, 2020
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this pull request Aug 5, 2020
* internal option

* external API

* testing

* lint

* clean

* seed in the transpiler

* simpler test

* latex support

* maxdiff

* docstring

* doc

* wire

* ket is special

* reno

* initial_state

* more refactor

* reno lint

* Update releasenotes/notes/initial_state_draw_parameter-f360ac4e998ee944.yaml

Co-Authored-By: Matthew Treinish <mtreinish@kortar.org>

* Update releasenotes/notes/initial_state_draw_parameter-f360ac4e998ee944.yaml

Co-Authored-By: Matthew Treinish <mtreinish@kortar.org>

* Update releasenotes/notes/initial_state_draw_parameter-f360ac4e998ee944.yaml

Co-Authored-By: Matthew Treinish <mtreinish@kortar.org>

* release note

* release note section

* examples with text drawer

* import

* maybe with an extra space

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: API Change Include in the "Changed" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants