-
Notifications
You must be signed in to change notification settings - Fork 594
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
[WIP][Bug Fix] Fixing the pow
method on qml.TShift
#6356
base: master
Are you sure you want to change the base?
Conversation
Hello. You may have forgotten to update the changelog!
|
@@ -168,7 +173,7 @@ def test_no_pow_ops(self, op): | |||
assert len(op_pow) == 1 | |||
assert op_pow[0].__class__ == op.__class__ | |||
|
|||
pows = [0.1, 2, -2, -2.5] | |||
pows = [0.1, -2.5] |
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.
pows = [0.1, -2.5] | |
pows = [0.1, -2, -2.5] |
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.
-2
should not raise PowUndefinedError
since -2 % 4 = 2
is what gets passed into pow
which is now defined. Maybe this test is not necessary since THadamard
is tested in test_period_two_three_noninteger_power
🤔
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.
Where is the %4
?
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.
Oh I just realized that this is a test for qutrit ops
Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
pow
method on qml.TShift
pow
method on qml.TShift
This PR fixes issue #6355 by providing proper
pow
implementations forqml.TShift
,qml.TAdd
, andqml.TClock
. Each of these operators implementpow
in the following way.This is calling the
pow
method onOperator
which handles the cases forz==0
andz==1
but returns aPowUndefinedError
for any other value ofz
. This leads to an error forTShift
,TAdd
, andTClock
when raising to the second power. This PR implements the case whenz
is a non-negative integer by returning a list containingz
copies of the operator.