class_docstr: Tests for the expand_matrix helper function.
class_docstr_tok: ["Tests","for","the","expand_matrix","helper","function","."]
docstr: Test that a 1 qubit gate correctly expands to 3 qubits.
docstr_tok: ["Test","that","a","1","qubit","gate","correctly","expands","to","3","qubits","."]
code: def test_expand_one(self, tol):
      """Test that a 1 qubit gate correctly expands to 3 qubits."""
      U = np.array(
          [
              [0.83645892 - 0.40533293j, -0.20215326 + 0.30850569j],
              [-0.23889780 - 0.28101519j, -0.88031770 - 0.29832709j],
          ]
      )
      # test applied to wire 0
      res = qml.math.expand_matrix(U, [0], [0, 4, 9])
      expected = np.kron(np.kron(U, I), I)
      assert np.allclose(res, expected, atol=tol, rtol=0)
  
      # test applied to wire 4
      res = qml.math.expand_matrix(U, [4], [0, 4, 9])
      expected = np.kron(np.kron(I, U), I)
      assert np.allclose(res, expected, atol=tol, rtol=0)
  
      # test applied to wire 9
      res = qml.math.expand_matrix(U, [9], [0, 4, 9])
      expected = np.kron(np.kron(I, I), U)
      assert np.allclose(res, expected, atol=tol, rtol=0)
  
imports: from functools import reduce
  import numpy
  import pytest
  from gate_data import CNOT, II, SWAP, I, Toffoli
  from scipy.sparse import csr_matrix
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 13 for calling the TestExpandMatrix obj's underlying member method code with example usage: obj.test_expand_one(tol) without return types