Skip to content

Commit

Permalink
Merge pull request #1042 from qiboteam/miscellaneous
Browse files Browse the repository at this point in the history
Rename `gates.RXY` as `gates.RXXYY` and fix `gates.SYC` docstring
  • Loading branch information
renatomello authored Oct 12, 2023
2 parents 72d6e67 + e1186d4 commit 51233c2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions doc/source/api-reference/qibo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -654,10 +654,10 @@ Parametric ZX interaction (RZX)
:members:
:member-order: bysource

Parametric XX-YY interaction (RXY)
Parametric XX-YY interaction (RXXYY)
""""""""""""""""""""""""""""""""""

.. autoclass:: qibo.gates.RXY
.. autoclass:: qibo.gates.RXXYY
:members:
:member-order: bysource

Expand Down
2 changes: 1 addition & 1 deletion src/qibo/backends/npmatrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def RZX(self, theta):
dtype=self.dtype,
)

def RXY(self, theta):
def RXXYY(self, theta):
cos, sin = self.np.cos(theta / 2), self.np.sin(theta / 2)
return self.np.array(
[
Expand Down
10 changes: 5 additions & 5 deletions src/qibo/gates/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ class SYC(Gate):
Corresponding to the following unitary matrix
.. math::
\\text{fSim}(\\pi / 2, \\, \\pi / 6) = \\beging{pmatrix}
\\text{fSim}(\\pi / 2, \\, \\pi / 6) = \\begin{pmatrix}
1 & 0 & 0 & 0 \\\\
0 & 0 & -i & 0 \\\\
0 & -i & 0 & 0 \\\\
Expand Down Expand Up @@ -1746,7 +1746,7 @@ def decompose(self, *free, use_toffolis: bool = True) -> List[Gate]:
return [H(q1), CNOT(q0, q1), RZ(q1, theta), CNOT(q0, q1), H(q1)]


class RXY(_Rnn_):
class RXXYY(_Rnn_):
"""Parametric 2-qubit :math:`XX + YY` interaction, or rotation about :math:`XX + YY`-axis.
Corresponds to the following unitary matrix
Expand All @@ -1771,11 +1771,11 @@ class RXY(_Rnn_):

def __init__(self, q0, q1, theta, trainable=True):
super().__init__(q0, q1, theta, trainable)
self.name = "rxy"
self.draw_label = "RXY"
self.name = "rxxyy"
self.draw_label = "RXXYY"

def decompose(self, *free, use_toffolis: bool = True) -> List[Gate]:
"""Decomposition of :math:`\\text{R_{XY}}` up to global phase.
"""Decomposition of :math:`\\text{R_{XX-YY}}` up to global phase.
This decomposition has a global phase difference with respect to the
original gate due to a phase difference in :math:`\\left(\\sqrt{X}\\right)^{\\dagger}`.
Expand Down
14 changes: 7 additions & 7 deletions tests/test_gates_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,20 +854,20 @@ def test_rzx(backend):
assert gates.RZX(0, 1, theta).unitary


def test_rxy(backend):
def test_rxxyy(backend):
theta = 0.1234
nqubits = 2
initial_state = random_statevector(2**nqubits, backend=backend)
final_state = apply_gates(
backend,
[gates.RXY(0, 1, theta)],
[gates.RXXYY(0, 1, theta)],
nqubits=nqubits,
initial_state=initial_state,
)
# test decomposition
final_state_decompose = apply_gates(
backend,
gates.RXY(0, 1, theta).decompose(),
gates.RXXYY(0, 1, theta).decompose(),
nqubits=nqubits,
initial_state=initial_state,
)
Expand Down Expand Up @@ -897,10 +897,10 @@ def test_rxy(backend):
)

with pytest.raises(NotImplementedError):
gates.RXY(0, 1, theta).qasm_label
gates.RXXYY(0, 1, theta).qasm_label

assert not gates.RXY(0, 1, theta).clifford
assert gates.RXY(0, 1, theta).unitary
assert not gates.RXXYY(0, 1, theta).clifford
assert gates.RXXYY(0, 1, theta).unitary


def test_ms(backend):
Expand Down Expand Up @@ -1423,7 +1423,7 @@ def test_controlled_unitary_matrix(backend):
("RYY", (0, 1, 0.2)),
("RZZ", (0, 1, 0.3)),
("RZX", (0, 1, 0.4)),
("RXY", (0, 1, 0.5)),
("RXXYY", (0, 1, 0.5)),
("MS", (0, 1, 0.1, 0.2, 0.3)),
("GIVENS", (0, 1, 0.1)),
("RBS", (0, 1, 0.2)),
Expand Down

0 comments on commit 51233c2

Please sign in to comment.