class_docstr: Tests for the density matrix function
class_docstr_tok: ["Tests","for","the","density","matrix","function"]
docstr: Test that the correct density matrix is returned
  for a full product state on two wires.
docstr_tok: ["Test","that","the","correct","density","matrix","is","returned","for","a","full","product","state","on","two","wires","."]
code: def test_correct_density_matrix_product_state_both(
      self, dev_name, return_wire_order
  ):
      """Test that the correct density matrix is returned
      for a full product state on two wires."""
  
      dev = qml.device(dev_name, wires=2)
  
      @qml.qnode(dev)
      def func():
          qml.Hadamard(wires=1)
          qml.PauliY(wires=0)
          return density_matrix(return_wire_order)
  
      density_both = func()
      single_statevectors = [[0, 1j], [1 / np.sqrt(2), 1 / np.sqrt(2)]]
      expected_statevector = np.kron(
          *[single_statevectors[w] for w in return_wire_order]
      )
      expected = np.outer(
          expected_statevector.conj(), expected_statevector
      )
  
      assert np.allclose(expected, density_both)
  
      if dev_name != "default.mixed":
          assert np.allclose(
              expected,
              qml.density_matrix(wires=return_wire_order).process_state(
                  state=dev.state, wire_order=dev.wires
              ),
          )
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.devices import DefaultQubitLegacy
  from pennylane.measurements import State, Shots, density_matrix, expval, state
label_desc: Use image node_id 8 for calling the TestDensityMatrix obj's underlying member method code with example usage: obj.test_correct_density_matrix_product_state_both(dev_name, return_wire_order) and returns: density_matrix