class_docstr: Tests for the func_to_unitary function
class_docstr_tok: ["Tests","for","the","func_to_unitary","function"]
docstr: Test for a fixed example if the returned unitary behaves as expected
  when used within a PennyLane circuit, i.e., so that the probability of the final control
  wire encodes the function.
docstr_tok: ["Test","for","a","fixed","example","if","the","returned","unitary","behaves","as","expected","when","used","within","a","PennyLane","circuit",",","i.e.",",","so","that","the","probability","of","the","final","control","wire","encodes","the","function","."]
code: def test_example_with_pl(self):
      """Test for a fixed example if the returned unitary behaves as expected
      when used within a PennyLane circuit, i.e., so that the probability of the final control
      wire encodes the function."""
      wires = 3
      M = 2**wires
      func = lambda i: np.sin(i) ** 2
  
      r = func_to_unitary(func, M)
  
      dev = qml.device("default.qubit", wires=(wires + 1))
  
      @qml.qnode(dev)
      def apply_r(input_state):
          qml.StatePrep(input_state, wires=range(wires))
          qml.QubitUnitary(r, wires=range(wires + 1))
          return qml.probs(wires)
  
      for i, state in enumerate(np.eye(M)):
          p = apply_r(state)[1]
          assert np.allclose(p, func(i))
  
imports: import numpy
  import pytest
  from scipy.stats import norm
  import pennylane
  from pennylane.templates.subroutines.qmc import QuantumMonteCarlo, _make_V, _make_Z, func_to_unitary, make_Q, probs_to_unitary
  from pennylane.wires import Wires
label_desc: Use image node_id 4 for calling the TestFuncToUnitary obj's underlying member method code with example usage: obj.test_example_with_pl() and returns: qml