code: def check_param_types(param, types, map_func, init, objs, keys):
      """Check that parameter setValue() accepts or rejects the correct types and
      that value() returns the correct type.
  
      Parameters
      ----------
          param : Parameter instance
          types : type or tuple of types
              The allowed types for this parameter to return from value().
          map_func : function
              Converts an input value to the expected output value.
          init : object
              The expected initial value of the parameter
          objs : dict
              Contains a variety of objects that will be tested as arguments to
              param.setValue().
          keys : list
              The list of keys indicating the valid objects in *objs*. When
              param.setValue() is teasted with each value from *objs*, we expect
              an exception to be raised if the associated key is not in *keys*.
      """
      val = param.value()
      if not isinstance(types, tuple):
          types = (types,)
      assert val == init and type(val) in types
  
      # test valid input types
      good_inputs = [objs[k] for k in keys if k in objs]
      good_outputs = map(map_func, good_inputs)
      for x, y in zip(good_inputs, good_outputs):
          param.setValue(x)
          val = param.value()
          if not (eq(val, y) and type(val) in types):
              raise Exception(
                  "Setting parameter %s with value %r should have resulted in %r (types: %r), "
                  "but resulted in %r (type: %r) instead."
                  % (param, x, y, types, val, type(val))
              )
  
      # test invalid input types
      for k, v in objs.items():
          if k in keys:
              continue
          try:
              param.setValue(v)
          except (TypeError, ValueError, OverflowError):
              continue
          except Exception as exc:
              raise Exception(
                  "Setting %s parameter value to %r raised %r."
                  % (param, v, exc)
              )
  
          raise Exception(
              "Setting %s parameter value to %r should have raised an exception."
              % (param, v)
          )
  
file_path: pyqtgraph/tests/parametertree/test_parametertypes.py
imports: from unittest.mock import MagicMock
  import numpy
  import pyqtgraph
  import pyqtgraph.parametertree
  from pyqtgraph.functions import eq
  from pyqtgraph.parametertree.parameterTypes import ChecklistParameterItem
  from pyqtgraph.Qt import QtCore, QtGui
label_desc: Use image node_id 4 for calling a global function with example usage: check_param_types(param, types, map_func, init, objs, keys) without return types