class_docstr: Tests for the density matrix function
class_docstr_tok: ["Tests","for","the","density","matrix","function"]
docstr: Test that the correct density matrix for an example with a mixed state
docstr_tok: ["Test","that","the","correct","density","matrix","for","an","example","with","a","mixed","state"]
code: def test_correct_density_matrix_mixed_state(self, dev_name):
      """Test that the correct density matrix for an example with a mixed state"""
  
      dev = qml.device(dev_name, wires=2)
  
      @qml.qnode(dev)
      def func():
          qml.Hadamard(0)
          qml.CNOT(wires=[0, 1])
          return qml.density_matrix(wires=[1])
  
      density = func()
  
      assert np.allclose(
          np.array(
              [[0.5 + 0.0j, 0.0 + 0.0j], [0.0 + 0.0j, 0.5 + 0.0j]]
          ),
          density,
      )
  
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 12 for calling the TestDensityMatrix obj's underlying member method code with example usage: obj.test_correct_density_matrix_mixed_state(dev_name) and returns: qml