class_docstr: Test the new VQE syntax of passing the Hamiltonian as an observable.
class_docstr_tok: ["Test","the","new","VQE","syntax","of","passing","the","Hamiltonian","as","an","observable","."]
docstr: Tests a VQE circuit where the observable does not act on all wires.
docstr_tok: ["Tests","a","VQE","circuit","where","the","observable","does","not","act","on","all","wires","."]
code: def test_acting_on_subcircuit(self, tol):
      """Tests a VQE circuit where the observable does not act on all wires."""
      dev = qml.device("default.qubit", wires=3)
      coeffs = [1.0, 1.0, 1.0]
      np.random.seed(1967)
      w = np.random.random(
          qml.templates.StronglyEntanglingLayers.shape(
              n_layers=1, n_wires=2
          )
      )
  
      observables1 = [qml.PauliZ(0), qml.PauliY(0), qml.PauliZ(1)]
      H1 = qml.Hamiltonian(coeffs, observables1)
  
      @qml.qnode(dev)
      def circuit1():
          qml.templates.StronglyEntanglingLayers(w, wires=range(2))
          return qml.expval(H1)
  
      observables2 = [
          qml.PauliZ(0),
          qml.PauliY(0),
          qml.PauliZ(1) @ qml.Identity(2),
      ]
      H2 = qml.Hamiltonian(coeffs, observables2)
  
      @qml.qnode(dev)
      def circuit2():
          qml.templates.StronglyEntanglingLayers(w, wires=range(2))
          return qml.expval(H2)
  
      res1 = circuit1()
      res2 = circuit2()
  
      assert np.allclose(res1, res2, atol=tol)
  
imports: import copy
  import numpy
  import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 2 for calling the TestNewVQE obj's underlying member method code with example usage: obj.test_acting_on_subcircuit(tol) and returns: qml, qml