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 CV simulator.
docstr_tok: ["Test","that","multiple","snapshots","are","returned","correctly","on","the","CV","simulator","."]
code: def test_default_gaussian(self, method):
      """Test that multiple snapshots are returned correctly on the CV simulator."""
      dev = qml.device("default.gaussian", wires=2)
  
      @qml.qnode(dev, diff_method=method)
      def circuit():
          qml.Snapshot()
          qml.Displacement(0.5, 0, wires=0)
          qml.Snapshot("very_important_state")
          qml.Beamsplitter(0.5, 0.7, wires=[0, 1])
          qml.Snapshot()
          return qml.expval(qml.QuadX(0))
  
      circuit()
      assert dev._debugger is None
  
      result = qml.snapshots(circuit)()
      expected = {
          0: {
              "cov_matrix": np.array(
                  [
                      [1, 0, 0, 0],
                      [0, 1, 0, 0],
                      [0, 0, 1, 0],
                      [0, 0, 0, 1],
                  ]
              ),
              "means": np.array([0, 0, 0, 0]),
          },
          1: {
              "cov_matrix": np.array(
                  [
                      [1, 0, 0, 0],
                      [0, 1, 0, 0],
                      [0, 0, 1, 0],
                      [0, 0, 0, 1],
                  ]
              ),
              "means": np.array([1, 0, 0, 0]),
          },
          2: {
              "cov_matrix": np.array(
                  [
                      [1, 0, 0, 0],
                      [0, 1, 0, 0],
                      [0, 0, 1, 0],
                      [0, 0, 0, 1],
                  ]
              ),
              "means": np.array(
                  [0.87758256, 0.36668488, 0, 0.30885441]
              ),
          },
          "execution_results": np.array(0.87758256),
      }
  
      assert all(
          k1 == k2 for k1, k2 in zip(result.keys(), expected.keys())
      )
      assert np.allclose(
          result["execution_results"], expected["execution_results"]
      )
      del result["execution_results"]
      del expected["execution_results"]
      assert all(
          np.allclose(v1["cov_matrix"], v2["cov_matrix"])
          for v1, v2 in zip(result.values(), expected.values())
      )
      assert all(
          np.allclose(v1["means"], v2["means"])
          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 4 for calling the TestSnapshot obj's underlying member method code with example usage: obj.test_default_gaussian(method) and returns: qml