Skip to content

Commit 55047ad

Browse files
committed
Update select_pauli_rot_phase_gradient.py
1 parent c0a61e0 commit 55047ad

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

pennylane/labs/transforms/select_pauli_rot_phase_gradient.py

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# Copyright 2018-2025 Xanadu Quantum Technologies Inc.
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
r"""
15+
Contains the select_pauli_rot transform.
16+
"""
117
import numpy as np
218

319
import pennylane as qml
@@ -19,6 +35,7 @@ def _binary_repr_int(phi, precision):
1935
]
2036

2137

38+
# pylint: disable=too-many-arguments
2239
def _select_pauli_rot_phase_gradient(
2340
phis: list,
2441
control_wires: Wires,
@@ -55,7 +72,7 @@ def _select_pauli_rot_phase_gradient(
5572
)
5673
)
5774

58-
return ops
75+
return qml.prod(*ops)
5976

6077

6178
@transform
@@ -106,48 +123,34 @@ def select_pauli_rot_phase_gradient(
106123

107124
angles = op.parameters[0]
108125

126+
pg_op = _select_pauli_rot_phase_gradient(
127+
angles,
128+
control_wires=control_wires,
129+
target_wire=target_wire,
130+
angle_wires=angle_wires,
131+
phase_grad_wires=phase_grad_wires,
132+
work_wires=work_wires,
133+
)
134+
109135
match rot_axis:
110136
case "X":
111137
operations.append(
112138
qml.change_op_basis(
113139
qml.Hadamard(target_wire),
114-
qml.ops.prod(_select_pauli_rot_phase_gradient)(
115-
angles,
116-
control_wires=control_wires,
117-
target_wire=target_wire,
118-
angle_wires=angle_wires,
119-
phase_grad_wires=phase_grad_wires,
120-
work_wires=work_wires,
121-
),
140+
pg_op,
122141
qml.Hadamard(target_wire),
123142
)
124143
)
125144
case "Y":
126145
operations.append(
127146
qml.change_op_basis(
128147
qml.Hadamard(target_wire) @ qml.adjoint(qml.S(target_wire)),
129-
qml.ops.prod(_select_pauli_rot_phase_gradient)(
130-
angles,
131-
control_wires=control_wires,
132-
target_wire=target_wire,
133-
angle_wires=angle_wires,
134-
phase_grad_wires=phase_grad_wires,
135-
work_wires=work_wires,
136-
),
148+
pg_op,
137149
qml.S(target_wire) @ qml.Hadamard(target_wire),
138150
)
139151
)
140152
case "Z":
141-
operations.append(
142-
qml.prod(_select_pauli_rot_phase_gradient)(
143-
angles,
144-
control_wires=control_wires,
145-
target_wire=target_wire,
146-
angle_wires=angle_wires,
147-
phase_grad_wires=phase_grad_wires,
148-
work_wires=work_wires,
149-
)
150-
),
153+
operations.append(pg_op)
151154

152155
else:
153156
operations.append(op)

0 commit comments

Comments
 (0)