Skip to content

Commit

Permalink
rename to YXMinusXYInteractionGate
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsung committed Jan 3, 2022
1 parent e16e34e commit 6b1a1a6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions qiskit_nature/circuit/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
UVCCSD,
)

from .gates import RYXXYGate
from .gates import YXMinusXYInteractionGate

from .initial_states import HartreeFock, VSCF

Expand All @@ -87,5 +87,5 @@
"UVCC",
"UVCCSD",
"VSCF",
"RYXXYGate",
"YXMinusXYInteractionGate",
]
4 changes: 2 additions & 2 deletions qiskit_nature/circuit/library/gates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
# that they have been altered from the originals.
"""Qiskit Nature Circuit Library Gates."""

from .ryxxy import RYXXYGate
from .ryxxy import YXMinusXYInteractionGate

__all__ = ["RYXXYGate"]
__all__ = ["YXMinusXYInteractionGate"]
4 changes: 2 additions & 2 deletions qiskit_nature/circuit/library/gates/ryxxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from qiskit.circuit.parameterexpression import ParameterValueType


class RYXXYGate(Gate):
class YXMinusXYInteractionGate(Gate):
r"""A parametric 2-qubit :math:`Y \otimes X - X \otimes Y` interaction.
These gates are used in the Givens rotation strategy for preparing
Expand Down Expand Up @@ -145,4 +145,4 @@ def _define(self):
def inverse(self):
"""Return inverse RYXXY gate."""
(theta,) = self.params
return RYXXYGate(-theta)
return YXMinusXYInteractionGate(-theta)
16 changes: 8 additions & 8 deletions test/circuit/library/gates/test_ryxxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,39 @@

from qiskit import QuantumCircuit
from qiskit.quantum_info import Operator
from qiskit_nature.circuit.library import RYXXYGate
from qiskit_nature.circuit.library import YXMinusXYInteractionGate


class TestRYXXYGate(QiskitNatureTestCase):
"""Tests for RYXXY gate"""

def test_matrix(self):
"""Test matrix."""
gate = RYXXYGate(0)
gate = YXMinusXYInteractionGate(0)
expected = np.eye(4)
np.testing.assert_allclose(gate.to_matrix(), expected, atol=1e-7)

gate = RYXXYGate(np.pi / 4)
gate = YXMinusXYInteractionGate(np.pi / 4)
a = np.sqrt(2) / 2
expected = np.array([[1, 0, 0, 0], [0, a, a, 0], [0, -a, a, 0], [0, 0, 0, 1]])
np.testing.assert_allclose(gate.to_matrix(), expected, atol=1e-7)

gate = RYXXYGate(np.pi / 2)
gate = YXMinusXYInteractionGate(np.pi / 2)
expected = np.array([[1, 0, 0, 0], [0, 0, 1, 0], [0, -1, 0, 0], [0, 0, 0, 1]])
np.testing.assert_allclose(gate.to_matrix(), expected, atol=1e-7)

gate = RYXXYGate(np.pi)
gate = YXMinusXYInteractionGate(np.pi)
expected = np.array([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
np.testing.assert_allclose(gate.to_matrix(), expected, atol=1e-7)

gate = RYXXYGate(2 * np.pi)
gate = YXMinusXYInteractionGate(2 * np.pi)
expected = np.eye(4)
np.testing.assert_allclose(gate.to_matrix(), expected, atol=1e-7)

def test_inverse(self):
"""Test inverse."""
theta = np.random.uniform(-10, 10)
gate = RYXXYGate(theta)
gate = YXMinusXYInteractionGate(theta)
circuit = QuantumCircuit(2)
circuit.append(gate, [0, 1])
circuit.append(gate.inverse(), [0, 1])
Expand All @@ -58,7 +58,7 @@ def test_inverse(self):
def test_decompose(self):
"""Test decomposition."""
theta = np.random.uniform(-10, 10)
gate = RYXXYGate(theta)
gate = YXMinusXYInteractionGate(theta)
circuit = QuantumCircuit(2)
circuit.append(gate, [0, 1])
decomposed_circuit = circuit.decompose()
Expand Down

0 comments on commit 6b1a1a6

Please sign in to comment.