diff --git a/mpitests/test_adjoint_jacobian.py b/mpitests/test_adjoint_jacobian.py index ea95aafbf..9bc92779e 100644 --- a/mpitests/test_adjoint_jacobian.py +++ b/mpitests/test_adjoint_jacobian.py @@ -103,9 +103,9 @@ def circuit(): qml.RX(0.4, wires=[0]) return qml.expval(qml.PauliZ(0)) - qnode = QNode(circuit, dev, diff_method="adjoint") + result = QNode(circuit, dev, diff_method="adjoint") - jac = qml.grad(qnode)() + jac = qml.grad(result)() assert len(jac) == 0 @@ -222,7 +222,18 @@ def test_Rot_gradient(self, stateprep, theta, batch_obs, dev): @pytest.mark.parametrize("param", [1, -2, 1.623, -0.051, 0]) # integers, floats, zero @pytest.mark.parametrize( "rotation,obs,expected_func", - [(qml.RY, qml.PauliX, lambda x: np.cos(x)), (qml.RX, qml.PauliZ, lambda x: -np.sin(x))], + [ + ( + qml.RY, + qml.PauliX, + lambda x: np.cos(x) + ), + ( + qml.RX, + qml.PauliZ, + lambda x: -np.sin(x) + ), + ], ) @pytest.mark.parametrize("batch_obs", [True, False]) def test_r_gradient( diff --git a/mpitests/test_expval.py b/mpitests/test_expval.py index c7d600d18..43ca43122 100644 --- a/mpitests/test_expval.py +++ b/mpitests/test_expval.py @@ -135,9 +135,6 @@ def test_expval_single_wire_no_parameters(self, tol, operation, wires, C_DTYPE, """Tests that expectation values are properly calculated for single-wire observables without parameters.""" num_wires = numQubits comm = MPI.COMM_WORLD - commSize = comm.Get_size() - num_global_wires = commSize.bit_length() - 1 - num_local_wires = num_wires - num_global_wires dev_mpi = qml.device( "lightning.gpu", wires=numQubits, mpi=True, c_dtype=C_DTYPE, batch_obs=batch_obs @@ -436,5 +433,7 @@ def circuit(): expected_val = -( np.cos(varphi) * np.sin(phi) + np.sin(varphi) * np.cos(theta) ) / np.sqrt(2) + else: + expected_val = 0 assert np.allclose(res, expected_val, atol=tol)