class_docstr: Test a wrapstruct with value labeling
class_docstr_tok: ["Test","a","wrapstruct","with","value","labeling"]
code: def test_get_value_label(self):
      # Test get value label method
      # Make a new class to avoid overwriting recoders of original
      class MyHdr(self.header_class):
          _field_recoders = {}
  
      hdr = MyHdr()
      # Key not existing raises error
      with pytest.raises(ValueError):
          hdr.get_value_label("improbable")
      # Even if there is a recoder
      assert "improbable" not in hdr.keys()
      rec = Recoder([[0, "fullness of heart"]], ("code", "label"))
      hdr._field_recoders["improbable"] = rec
      with pytest.raises(ValueError):
          hdr.get_value_label("improbable")
      # If the key exists in the structure, and is intable, then we can recode
      for key, value in hdr.items():
          # No recoder at first
          with pytest.raises(ValueError):
              hdr.get_value_label(0)
          if not value.dtype.type in INTEGER_TYPES or not np.isscalar(
              value
          ):
              continue
          code = int(value)
          rec = Recoder(
              [[code, "fullness of heart"]], ("code", "label")
          )
          hdr._field_recoders[key] = rec
          assert hdr.get_value_label(key) == "fullness of heart"
          # If key exists, but value is missing, we get 'unknown code'
          # Speculating that we can set code value 0 or 1
          new_code = 1 if code == 0 else 0
          hdr[key] = new_code
          assert (
              hdr.get_value_label(key) == f"<unknown code {new_code}>"
          )
  
imports: import logging
  from io import BytesIO, StringIO
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from ..None import imageglobals
  from ..batteryrunners import Report
  from ..casting import sctypes
  from ..spatialimages import HeaderDataError
  from ..volumeutils import Recoder, native_code, swapped_code
  from ..wrapstruct import LabeledWrapStruct, WrapStruct, WrapStructError
label_desc: Use image node_id 1 for calling the _TestLabeledWrapStruct obj's underlying member method code with example usage: obj.test_get_value_label() without return types