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 using JAX-JIT if the returned unitary maps input states to the
  expected output state as well as if the unitary satisfies U @ U.T = U.T @ U = I.
docstr_tok: ["Test","for","a","fixed","example","using","JAX-JIT","if","the","returned","unitary","maps","input","states","to","the","expected","output","state","as","well","as","if","the","unitary","satisfies","U","@","U.T","=","U.T","@","U","=","I","."]
code: def test_example_jax_jit(self):
      """Test for a fixed example using JAX-JIT if the returned unitary maps input states to the
      expected output state as well as if the unitary satisfies U @ U.T = U.T @ U = I.
      """
      import jax
      from jax import numpy as jnp
  
      M = 8
      func = lambda i: jnp.sin(i) ** 2
  
      r = func_to_unitary(jax.jit(func), M)
  
      for i in range(M):
          # The control qubit is the last qubit, so we have to look at every other term
          # using [::2].
          output_state = r[::2][i]
          output_0 = output_state[::2]
          output_1 = output_state[1::2]
          assert np.allclose(output_0[i], np.sqrt(1 - func(i)))
          assert np.allclose(output_1[i], np.sqrt(func(i)))
  
      assert np.allclose(r @ r.T, np.eye(2 * M), atol=1e-7)
      assert np.allclose(r.T @ r, np.eye(2 * M), atol=1e-7)
  
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 3 for calling the TestFuncToUnitary obj's underlying member method code with example usage: obj.test_example_jax_jit() without return types