class_docstr: Test the Snapshot instruction for simulators.
class_docstr_tok: ["Test","the","Snapshot","instruction","for","simulators","."]
docstr: Test that multiple snapshots are returned correctly on the density-matrix simulator.
docstr_tok: ["Test","that","multiple","snapshots","are","returned","correctly","on","the","density-matrix","simulator","."]
code: def test_default_mixed(self, method):
      """Test that multiple snapshots are returned correctly on the density-matrix simulator."""
      dev = qml.device("default.mixed", wires=2)
  
      @qml.qnode(dev, diff_method=method)
      def circuit():
          qml.Snapshot()
          qml.Hadamard(wires=0)
          qml.Snapshot("very_important_state")
          qml.CNOT(wires=[0, 1])
          qml.Snapshot()
          return qml.expval(qml.PauliX(0))
  
      circuit()
      assert dev._debugger is None
  
      result = qml.snapshots(circuit)()
      expected = {
          0: np.array(
              [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
          ),
          "very_important_state": np.array(
              [
                  [0.5, 0, 0.5, 0],
                  [0, 0, 0, 0],
                  [0.5, 0, 0.5, 0],
                  [0, 0, 0, 0],
              ]
          ),
          2: np.array(
              [
                  [0.5, 0, 0, 0.5],
                  [0, 0, 0, 0],
                  [0, 0, 0, 0],
                  [0.5, 0, 0, 0.5],
              ]
          ),
          "execution_results": np.array(0),
      }
  
      assert all(
          k1 == k2 for k1, k2 in zip(result.keys(), expected.keys())
      )
      assert all(
          np.allclose(v1, v2)
          for v1, v2 in zip(result.values(), expected.values())
      )
  
file_path: pennylane/tests/test_debugging.py
imports: import pytest
  import numpy
  import pennylane
label_desc: Use image node_id 3 for calling the TestSnapshot obj's underlying member method code with example usage: obj.test_default_mixed(method) and returns: qml