class_docstr: Test the Snapshot instruction for simulators.
class_docstr_tok: ["Test","the","Snapshot","instruction","for","simulators","."]
docstr: Test that the correct measurement snapshots are returned for different measurement types.
docstr_tok: ["Test","that","the","correct","measurement","snapshots","are","returned","for","different","measurement","types","."]
code: def test_all_measurement_snapshot(self):
      """Test that the correct measurement snapshots are returned for different measurement types."""
      dev = qml.device("default.qubit")
  
      @qml.qnode(dev)
      def circuit(x):
          qml.Snapshot(measurement=qml.expval(qml.PauliZ(0)))
          qml.RX(x, wires=0)
          qml.Snapshot(measurement=qml.var(qml.PauliZ(0)))
          qml.Snapshot(measurement=qml.probs(0))
          qml.Snapshot(measurement=qml.state())
          return qml.expval(qml.PauliZ(0))
  
      phi = 0.1
      result = qml.snapshots(circuit)(phi)
      expected = {
          0: np.array(1),
          1: np.array(1 - np.cos(phi) ** 2),
          2: np.array([np.cos(phi / 2) ** 2, np.sin(phi / 2) ** 2]),
          3: np.array([np.cos(phi / 2), -1j * np.sin(phi / 2)]),
          "execution_results": np.array(np.cos(phi)),
      }
  
      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 12 for calling the TestSnapshot obj's underlying member method code with example usage: obj.test_all_measurement_snapshot() and returns: qml