-
Notifications
You must be signed in to change notification settings - Fork 61
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
Add gate labels #853
Add gate labels #853
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #853 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 48 48
Lines 6169 6309 +140
==========================================
+ Hits 6169 6309 +140
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
the parameters For instance, any time that I haven't looked at every instance in which |
Looking at the changes, I also agree that we could keep only one attribute for
I also do not recall all the places where |
@renatomello @stavros11 thank you for the comments, I will look into replacing |
At the moment,
|
Thanks a lot for checking, I agree for the proposal.
Feel free to rename this
Indeed, removing
Maybe you could make this a class Gate:
@property
def qasm_label(self):
raise_error(NotImplementedError, f"{self.__class__.__name__} is not supported by OpenQASM")
class H(Gate):
@property
def qasm_label(self):
return "h" In principle we could also consider removing |
for more information, see https://pre-commit.ci
Thank you @stavros11. Turning |
is this dictionary Line 8 in e6afcd5
|
Yes, this dictionary is needed for |
@stavros11 could you also check this before we merge? |
@vodovozovaliza since |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates, looks good to me too. I just left a comment regarding removing the PARAMETRIZED_GATES
set. This is not strictly required to merge but since you already cleaned the other dictionaries in gates.py, it may be a good idea to do so.
If understand correctly now the user is able to control both the name
and the draw_label
seperately. Is this okay for your applications or you prefer the draw_label
to change every time the name
changes? If that's the case we may need to have a setter or drop completely the draw_label
and use only the name
(but then we lose the flexibility of adjusting them seperately).
Thank you for this comment, I removed
The purpose of draw_label = "".join([c for c in gate.name if c.isupper() or c.isdigit()][:4])
if len(draw_label) == 0:
draw_label = gate.name[:4].upper()
# "KrausChannel1" -> "KC1"
# "x" -> "X" However, I think it is good to have the flexibility of controlling |
Thanks for the explanation and update. This was mostly a question towards the users of these features, to me the current solution is fine as it is the most flexible. I agree with merging this. |
Related to issue #850. This PR allows to change
name
parameter ofqibo.gates.Gate
and 2 other labels are added:name
: label of the gate. Can be changed by a user.draw_label
: a symbol for drawing a circuit. IfNone
or empty,gate.name[:4]
is used.This parameter allows to remove
qibo.gates.DRAW_LABELS
dictionary.@property qasm_label
: for gates supported by OpenQASM.For example:
prints
instead of
As mentioned in #850, the
name
can be used for NoiseModels or for controlling parameters of the quantum hardware.Checklist: