class_docstr: Unit tests for the to_openqasm() method
class_docstr_tok: ["Unit","tests","for","the","to_openqasm","(",")","method"]
docstr: Test that the Mottonen state prepration decomposition
  is correctly applied.
docstr_tok: ["Test","that","the","Mottonen","state","prepration","decomposition","is","correctly","applied","."]
code: def test_state_initialization_decomposition(self):
      """Test that the Mottonen state prepration decomposition
      is correctly applied."""
      psi = np.array([1, -1, -1, 1]) / np.sqrt(4)
  
      with qml.queuing.AnnotatedQueue() as q1:
          qml.StatePrep(psi, wires=[0, 1])
  
      circuit1 = qml.tape.QuantumScript.from_queue(q1)
      qasm1 = circuit1.to_openqasm(precision=11)
  
      with qml.queuing.AnnotatedQueue() as q2:
          qml.StatePrep.compute_decomposition(psi, wires=[0, 1])
  
      circuit2 = qml.tape.QuantumScript.from_queue(q2)
      qasm2 = circuit2.to_openqasm(wires=Wires([0, 1]), precision=11)
  
      expected = dedent(
          """\
              OPENQASM 2.0;
              include "qelib1.inc";
              qreg q[2];
              creg c[2];
              ry(1.5707963268) q[0];
              ry(1.5707963268) q[1];
              cx q[0],q[1];
              cx q[0],q[1];
              cx q[0],q[1];
              rz(3.1415926536) q[1];
              cx q[0],q[1];
              measure q[0] -> c[0];
              measure q[1] -> c[1];
              """
      )
  
      # different
      assert qasm1 == expected
      assert qasm1 == qasm2
  
imports: from textwrap import dedent
  import numpy
  import pytest
  import pennylane
  from pennylane.wires import Wires
label_desc: Use image node_id 6 for calling the TestToQasmUnitTests obj's underlying member method code with example usage: obj.test_state_initialization_decomposition() without return types