Skip to content

Commit

Permalink
update template py tests
Browse files Browse the repository at this point in the history
  • Loading branch information
multiphaseCFD committed Sep 11, 2024
1 parent 6adbbc5 commit 7886310
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ def circuit(feature_vector):
class TestIQPEmbedding:
"""Test the IQPEmbedding algorithm."""

@pytest.mark.parametrize(
"n_qubits", range(2, 20, 2) if device_name != "lightning.tensor" else range(2, 16)
)
@pytest.mark.parametrize("n_qubits", range(2, 20, 2))
def test_iqpembedding(self, n_qubits):
if device_name == "lightning.tensor" and n_qubits > 14:
pytest.xfail(
"Inexact calculation for lightning.tensor with n_qubits > 14 since the default max mps bond dim is 2^7."
)
dev = qml.device(device_name, wires=n_qubits)
dq = qml.device("default.qubit")

Expand All @@ -193,10 +195,12 @@ def circuit(feature_vector):
class TestQAOAEmbedding:
"""Test the QAOAEmbedding algorithm."""

@pytest.mark.parametrize(
"n_qubits", range(2, 20, 2) if device_name != "lightning.tensor" else range(2, 16)
)
@pytest.mark.parametrize("n_qubits", range(2, 20, 2))
def test_qaoaembedding(self, n_qubits):
if device_name == "lightning.tensor" and n_qubits > 14:
pytest.xfail(
"Inexact calculation for lightning.tensor with n_qubits > 14 since the default max mps bond dim is 2^7."
)
dev = qml.device(device_name, wires=n_qubits)
dq = qml.device("default.qubit")

Expand Down Expand Up @@ -255,10 +259,12 @@ def circuit(weights):
class TestStronglyEntanglingLayers:
"""Test the StronglyEntanglingLayers algorithm."""

@pytest.mark.parametrize(
"n_qubits", range(2, 20, 2) if device_name != "lightning.tensor" else range(2, 16)
)
@pytest.mark.parametrize("n_qubits", range(2, 20, 2))
def test_stronglyentanglinglayers(self, n_qubits):
if device_name == "lightning.tensor" and n_qubits > 14:
pytest.xfail(
"Inexact calculation for lightning.tensor with n_qubits > 14 since the default max mps bond dim is 2^7."
)
dev = qml.device(device_name, wires=n_qubits)
dq = qml.device("default.qubit")

Expand All @@ -278,10 +284,12 @@ def circuit(weights):
class TestSimplifiedTwoDesign:
"""Test the SimplifiedTwoDesign algorithm."""

@pytest.mark.parametrize(
"n_qubits", range(2, 20, 2) if device_name != "lightning.tensor" else range(2, 16)
)
@pytest.mark.parametrize("n_qubits", range(2, 20, 2))
def test_simplifiedtwodesign(self, n_qubits):
if device_name == "lightning.tensor" and n_qubits > 14:
pytest.xfail(
"Inexact calculation for lightning.tensor with n_qubits > 14 since the default max mps bond dim is 2^7."
)
dev = qml.device(device_name, wires=n_qubits)
dq = qml.device("default.qubit")

Expand Down Expand Up @@ -717,10 +725,12 @@ def circuit():
class TestQFT:
"""Test the QFT algorithm."""

@pytest.mark.parametrize(
"n_qubits", range(2, 20, 2) if device_name != "lightning.tensor" else range(2, 14)
)
@pytest.mark.parametrize("n_qubits", range(2, 20, 2))
def test_qft(self, n_qubits):
if device_name == "lightning.tensor" and n_qubits > 14:
pytest.xfail(
"Inexact calculation for lightning.tensor with n_qubits > 14 since the default max mps bond dim is 2^7."
)
dev = qml.device(device_name, wires=n_qubits)
dq = qml.device("default.qubit")

Expand Down Expand Up @@ -778,10 +788,12 @@ def circuit(basis_state):
class TestQSVT:
"""Test the QSVT algorithm."""

@pytest.mark.parametrize(
"n_qubits", range(2, 20, 2) if device_name != "lightning.tensor" else range(2, 16)
)
@pytest.mark.parametrize("n_qubits", range(2, 20, 2))
def test_qsvt(self, n_qubits):
if device_name == "lightning.tensor" and n_qubits > 14:
pytest.xfail(
"Inexact calculation for lightning.tensor with n_qubits > 14 since the default max mps bond dim is 2^7."
)
dev = qml.device(device_name, wires=n_qubits)
dq = qml.device("default.qubit")
A = np.array([[0.1]])
Expand Down

0 comments on commit 7886310

Please sign in to comment.