class_docstr: Tests for the expand_matrix helper function.
class_docstr_tok: ["Tests","for","the","expand_matrix","helper","function","."]
docstr: Test that a broadcasted 3 qubit gate on consecutive
  wires correctly expands to 4 qubits.
docstr_tok: ["Test","that","a","broadcasted","3","qubit","gate","on","consecutive","wires","correctly","expands","to","4","qubits","."]
code: def test_expand_three_consecutive_wires_broadcasted(self, tol):
      """Test that a broadcasted 3 qubit gate on consecutive
      wires correctly expands to 4 qubits."""
      # test applied to wire 0,1,2
      res = qml.math.expand_matrix(
          Toffoli_broadcasted, [0, 1, 2], [0, 1, 2, 3]
      )
      expected = np.kron(Toffoli_broadcasted, I_broadcasted)
      assert np.allclose(res, expected, atol=tol, rtol=0)
  
      # test applied to wire 1,2,3
      res = qml.math.expand_matrix(
          Toffoli_broadcasted, [1, 2, 3], [0, 1, 2, 3]
      )
      expected = np.kron(I_broadcasted, Toffoli_broadcasted)
      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 20 for calling the TestExpandMatrix obj's underlying member method code with example usage: obj.test_expand_three_consecutive_wires_broadcasted(tol) without return types