class_docstr: Tests for the expand_matrix helper function.
class_docstr_tok: ["Tests","for","the","expand_matrix","helper","function","."]
docstr: Test that a 2 qubit gate on reversed consecutive wires correctly
  expands to 4 qubits.
docstr_tok: ["Test","that","a","2","qubit","gate","on","reversed","consecutive","wires","correctly","expands","to","4","qubits","."]
code: def test_expand_two_reversed_wires(self, tol):
      """Test that a 2 qubit gate on reversed consecutive wires correctly
      expands to 4 qubits."""
      # CNOT with target on wire 1
      res = qml.math.expand_matrix(CNOT, [1, 0], [0, 1, 2, 3])
      rows = np.array([0, 2, 1, 3])
      expected = np.kron(np.kron(CNOT[:, rows][rows], I), I)
      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 17 for calling the TestExpandMatrix obj's underlying member method code with example usage: obj.test_expand_two_reversed_wires(tol) without return types