Skip to content

implemented perform_y #8

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

gsilviHQS
Copy link

This is the first step in solving #7 implementing Ry gates (and possibly Rx,Rz)
Also added 2 new colors to handle the complex phase.

added 2 new colors to handle the complex phase
Copy link
Owner

@cduck cduck left a comment

Choose a reason for hiding this comment

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

Looks good, only come minor comments.

I will be out until the end of July so unfortunately I won't be able to review more of your code until August. Feel free to make more PRs for when I'm back.

@@ -4,7 +4,7 @@
from sympy.printing.latex import latex
import drawSvg as draw
import latextools

Copy link
Owner

Choose a reason for hiding this comment

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

No need to do this. Just use pi from import math.

self.straight_arrow(g, color, xx1, yy1, xx2, yy2, width=w)

def wheel_color(self,amp):
Copy link
Owner

Choose a reason for hiding this comment

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

Do you think this is enough colors for when you do Ry? Alternatively, use some continuous color map like HSV where hue is controlled by the phase (i.e. drawSvg.color.Hsv)

Copy link
Author

Choose a reason for hiding this comment

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

You are right, I was planning to update to a more continuous map later on when implementing the R* gates. I ll check the HSV

new_state[new_key] = 0
new_state[new_key] += new_amp
self.transition_text(self.d, t, f'{pre_latex}{name}_{{{q_i}}}')
self.add_states(new_state)
Copy link
Owner

Choose a reason for hiding this comment

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

Nice. If you intend to add many more gates, can you refactor the perform_* methods to avoid the code copy?

Copy link
Author

Choose a reason for hiding this comment

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

Will do. Shall I make a perform_gate class? Or do you have something better in mind?

Copy link
Owner

Choose a reason for hiding this comment

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

It could be as simple as a dictionary with symbolic gate unitaries (at least for single-qubit gates: {'X': [[0,1],[1,0]], ...}). A perform-gate class may just add more boilerplate code.

gsilviHQS and others added 3 commits July 6, 2022 08:50
Co-authored-by: Casey Duckering <[email protected]>
also command accept floats
and add simplify to amplitudes.
In case the amplitude is too complicated return the value in digits
@gsilviHQS
Copy link
Author

gsilviHQS commented Jul 8, 2022

I made the following changes:

  • factorized the single gates to reduce the code replication.
  • add a continuous color wheel for amplitudes
  • add Rx,Ry,Rz gate with half_turns
  • the command from terminal can accept floats
  • add a simplify to the amplitudes to avoid labels too complex ( this part add some overhead but I didn't find a better way to deal with it atm), and in case the simplification doesn't reduce enough it translates the symbolic amplitudes to simple digits (too keep a short label)
  • fixed a couple of mistakes in the readme examples

where you can follow the sign through the color of the lines
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.

2 participants