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

feature: update circuit drawing #846

Merged
merged 70 commits into from
Mar 6, 2024

Conversation

jcjaskula-aws
Copy link
Contributor

@jcjaskula-aws jcjaskula-aws commented Dec 22, 2023

Issue #, if available:
N, C characters are not conventional to denote (neg)controlled qubits.
Circuits can also look nicer by using box drawing characters.

Description of changes:

  • changed N and C to empty/full unicode circle
  • use box drawing characters
  • keep ascii diagram as legacy builder
  • move ascii_circuit_diagram.py and boxdrawing_circuit_diagram to text_circuit_diagram_builders/
  • create a text_circuit_diagram.py containing helper functions to reuse common code.

Testing done:
updated unit tests.

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jcjaskula-aws jcjaskula-aws requested a review from a team as a code owner December 22, 2023 22:06
@jcjaskula-aws jcjaskula-aws marked this pull request as draft December 22, 2023 22:08
@jcjaskula-aws jcjaskula-aws marked this pull request as ready for review December 22, 2023 22:09
Copy link

codecov bot commented Dec 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (b4245ea) to head (af08fe7).

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #846    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          129       132     +3     
  Lines         8618      8814   +196     
  Branches      1928      1987    +59     
==========================================
+ Hits          8618      8814   +196     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor Author

@jcjaskula-aws jcjaskula-aws left a comment

Choose a reason for hiding this comment

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

Looks like the wrong character is being used. On mobile it shows up as ⏺️. I believe ● is the correct character.

Was using U+25CB and U+25CF. I could find the large white circle (U+25EF) but not the black one. Eventually, I switch to the character you pasted in your comment and U+25EF, but I still could not find the unicode number for the large black circle.

@jcjaskula-aws jcjaskula-aws marked this pull request as draft December 27, 2023 05:28
@jcjaskula-aws jcjaskula-aws marked this pull request as ready for review December 27, 2023 17:03
@jcjaskula-aws jcjaskula-aws marked this pull request as draft February 23, 2024 16:50
@jcjaskula-aws jcjaskula-aws marked this pull request as ready for review February 23, 2024 18:33
@jcjaskula-aws jcjaskula-aws requested a review from krneta February 23, 2024 19:02
@jcjaskula-aws jcjaskula-aws changed the title Update circuit drawing feature: update circuit drawing Feb 23, 2024
src/braket/circuits/ascii_circuit_diagram.py Outdated Show resolved Hide resolved
src/braket/circuits/circuit.py Outdated Show resolved Hide resolved
src/braket/circuits/circuit.py Outdated Show resolved Hide resolved
test/unit_tests/braket/circuits/test_circuit.py Outdated Show resolved Hide resolved
@jcjaskula-aws jcjaskula-aws requested a review from krneta March 1, 2024 23:00
"""
top = ""
bottom = ""
if symbol in ["C", "N", "SWAP"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not crazy about hard-coding these (again?)... couldn't we just have put in the correct symbol on line 131? For SWAP, why are we not just changing the symbol in the class, rather than here?

Copy link
Contributor Author

@jcjaskula-aws jcjaskula-aws Mar 5, 2024

Choose a reason for hiding this comment

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

I'm concerned that gates like Cnot have harcoded ascii_symbol = ["C", "X"] that will be passed through L124. If we want to keep AsciiCircuitDiagram and UnicodeCircuitDiagram living together, I believe it is easier to transform control qubit symbols as late as possible.

I think it is also better to transform SWAP later than earlier. If we change the ascii_symbol, we will need an exception in _draw_symbol because we should avoid boxing the symbol x (which will look like an x gate then).

@jcjaskula-aws jcjaskula-aws merged commit c49176b into main Mar 6, 2024
24 checks passed
@jcjaskula-aws jcjaskula-aws deleted the jcjaskula-aws/update-ascii-diagram branch March 6, 2024 20:10
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.

6 participants