Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lillian542 committed Nov 19, 2024
1 parent 5eb346f commit 4f68dfb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
19 changes: 0 additions & 19 deletions test/unit_tests/test_ahs_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,25 +467,6 @@ def test_check_validity_valid_circuit(self, H, params):

dev.check_validity(ops, obs)

@pytest.mark.parametrize("H, params", HAMILTONIANS_AND_PARAMS)
def test_check_validity_valid_circuit_no_op_math(self, H, params):
"""Tests that check_validity() doesn't raise any errors when the operations and
observables are valid."""
qml.operation.disable_new_opmath()
ops = [ParametrizedEvolution(H, params, [0, 1.5])]
obs = [
qml.PauliZ(0),
qml.expval(qml.PauliZ(0)),
qml.var(qml.Identity(0)),
qml.sample(qml.PauliZ(0)),
qml.prod(qml.PauliZ(0), qml.Identity(1)),
qml.Hamiltonian([2, 3], [qml.PauliZ(0), qml.PauliZ(1)]),
qml.counts(),
]
dev = qml.device("braket.local.ahs", wires=3)

dev.check_validity(ops, obs)

@pytest.mark.parametrize("H, params", HAMILTONIANS_AND_PARAMS)
def test_check_validity_raises_error_for_state_based_measurement(self, H, params):
"""Tests that requesting a measurement other than a sample-based
Expand Down
7 changes: 4 additions & 3 deletions test/unit_tests/test_braket_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ def test_execute_with_gradient_no_op_math(
result_types,
expected_pl_result,
):
qml.operation.disable_new_opmath()

task = Mock()
type(task).id = PropertyMock(return_value="task_arn")
Expand Down Expand Up @@ -830,8 +829,8 @@ def test_pl_to_braket_circuit_hamiltonian():


def test_pl_to_braket_circuit_hamiltonian_tensor_product_terms():
"""Tests that a PennyLane circuit is correctly converted into a Braket circuit"""
"""when the Hamiltonian has multiple tensor product ops"""
"""Tests that a PennyLane circuit is correctly converted into a Braket circuit
when the Hamiltonian has multiple tensor product ops"""
dev = _aws_device(wires=2, foo="bar")

with QuantumTape() as tape:
Expand Down Expand Up @@ -1314,6 +1313,8 @@ def test_execute_some_samples(mock_run):
mock_run.return_value = task
dev = _aws_device(wires=3)

print(type(qml.Hadamard(0) @ qml.Identity(1)))

with QuantumTape() as circuit:
qml.Hadamard(wires=0)
qml.CNOT(wires=[0, 1])
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/test_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ def test_translate_result_type_hamiltonian_unsupported_return(return_type):
with Hamiltonian observable and non-Expectation return type"""
obs = qml.Hamiltonian((2, 3), (qml.PauliX(wires=0), qml.PauliY(wires=1)))
tape = qml.tape.QuantumTape(measurements=[_braket_to_pl_result_types[return_type](obs)])
with pytest.raises(NotImplementedError, match="unsupported for Hamiltonian"):
with pytest.raises(NotImplementedError, match="unsupported for LinearCombination"):
translate_result_type(tape.measurements[0], [0], frozenset())


Expand Down

0 comments on commit 4f68dfb

Please sign in to comment.