class_docstr: Tests general operations.
class_docstr_tok: ["Tests","general","operations","."]
docstr: Test that `qml.Snapshot` works properly with `tape_mpl`.
code: def test_snapshot(self):
      """Test that `qml.Snapshot` works properly with `tape_mpl`."""
  
      # Test that empty figure is created when the only gate is `qml.Snapshot`
      tape = QuantumScript([qml.Snapshot()])
      fig, ax = tape_mpl(tape)
  
      assert isinstance(fig, mpl.figure.Figure)
      assert isinstance(ax, mpl.axes._axes.Axes)
  
      assert fig.axes == [ax]
  
      # Test that `qml.Snapshot` works properly when other gates are present
      tape = QuantumScript(
          [
              qml.Snapshot(),
              qml.Hadamard(0),
              qml.Hadamard(1),
              qml.Hadamard(2),
          ]
      )
      _, ax = tape_mpl(tape)
  
      assert isinstance(ax.patches[0], mpl.patches.FancyBboxPatch)
      assert ax.patches[0].get_x() == -self.width / 2.0
      assert ax.patches[0].get_y() == -self.width / 2.0
      assert ax.patches[0].get_width() == self.width
      assert ax.patches[0].get_height() == 2 + self.width
  
imports: import pytest
  import pennylane
  from pennylane.drawer import tape_mpl
  from pennylane.tape import QuantumScript
label_desc: Use image node_id 2 for calling the TestGeneralOperations obj's underlying member method code with example usage: obj.test_snapshot() without return types