code: def test_sugar():
      # Syntactic sugar for recoder class
      codes = ((1, "one", "1", "first"), (2, "two"))
      rc = Recoder(codes)
      # Field1 is synonym for first named dict
      assert rc.code == rc.field1
      rc = Recoder(codes, fields=("code1", "label"))
      assert rc.code1 == rc.field1
      # Direct key access identical to key access for first named
      assert rc[1] == rc.field1[1]
      assert rc["two"] == rc.field1["two"]
      # keys gets all keys
      assert set(rc.keys()) == {1, "one", "1", "first", 2, "two"}
      # value_set gets set of values from first column
      assert rc.value_set() == {1, 2}
      # or named column if given
      assert rc.value_set("label") == {"one", "two"}
      # "in" works for values in and outside the set
      assert "one" in rc
      assert "three" not in rc
  
file_path: nibabel/nibabel/tests/test_recoder.py
imports: import numpy
  import pytest
  from ..volumeutils import DtypeMapper, Recoder, native_code, swapped_code
label_desc: Use image node_id 9 for calling a global function with example usage: test_sugar() without return types