class_docstr: Test helper functions for the tape text.
docstr: Test private _add_measurement function with a matrix cache.
docstr_tok: ["Test","private","_add_measurement","function","with","a","matrix","cache","."]
code: def test_add_measurements_cache(self):
      """Test private _add_measurement function with a matrix cache."""
      cache = {"matrices": []}
      op = qml.expval(qml.Hermitian(np.eye(2), wires=0))
      assert _add_measurement(
          op,
          ["", ""],
          _Config(
              wire_map={0: 0, 1: 1},
              bit_map=default_bit_map,
              cache=cache,
          ),
      ) == [
          "<𝓗(M0)>",
          "",
      ]
  
      assert qml.math.allclose(cache["matrices"][0], np.eye(2))
  
      op2 = qml.expval(qml.Hermitian(np.eye(2), wires=1))
      # new op with same matrix, should have same M0 designation
      assert _add_measurement(
          op2,
          ["", ""],
          _Config(
              wire_map={0: 0, 1: 1},
              bit_map=default_bit_map,
              cache=cache,
          ),
      ) == [
          "",
          "<𝓗(M0)>",
      ]
  
imports: import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.drawer import tape_text
  from pennylane.drawer.tape_text import _add_grouping_symbols, _add_cond_grouping_symbols, _add_mid_measure_grouping_symbols, _add_cwire_measurement_grouping_symbols, _add_cwire_measurement, _add_measurement, _add_op, _Config
  from pennylane.tape import QuantumScript, QuantumTape
label_desc: Use image node_id 7 for calling the TestHelperFunctions obj's underlying member method code with example usage: obj.test_add_measurements_cache() without return types