class_docstr: Test that apply_operation works for Snapshot ops
class_docstr_tok: ["Test","that","apply_operation","works","for","Snapshot","ops"]
docstr: Test that an arbitrary measurement is recorded properly when a snapshot is created
docstr_tok: ["Test","that","an","arbitrary","measurement","is","recorded","properly","when","a","snapshot","is","created"]
code: def test_measurement(self, ml_framework):
      """Test that an arbitrary measurement is recorded properly when a snapshot is created"""
      initial_state = np.array(
          [
              [0.04624539 + 0.3895457j, 0.22399401 + 0.53870339j],
              [-0.483054 + 0.2468498j, -0.02772249 - 0.45901669j],
          ]
      )
      initial_state = qml.math.asarray(initial_state, like=ml_framework)
      measurement = qml.expval(qml.PauliZ(0))
  
      debugger = self.Debugger()
      new_state = apply_operation(
          qml.Snapshot(measurement=measurement),
          initial_state,
          debugger=debugger,
      )
  
      assert new_state.shape == initial_state.shape
      assert qml.math.allclose(new_state, initial_state)
  
      assert list(debugger.snapshots.keys()) == [0]
      assert debugger.snapshots[0].shape == ()
      assert debugger.snapshots[0] == qml.devices.qubit.measure(
          measurement, initial_state
      )
  
imports: from functools import reduce
  import pytest
  import numpy
  from scipy.stats import unitary_group
  import pennylane
  from pennylane.operation import _UNSET_BATCH_SIZE, Operation
  from pennylane.devices.qubit.apply_operation import apply_operation, apply_operation_einsum, apply_operation_tensordot
label_desc: Use image node_id 4 for calling the TestSnapshot obj's underlying member method code with example usage: obj.test_measurement(ml_framework) without return types