code: def test_test_objects_rand_index():
      r = numpy.random.RandomState()
      r.seed(52)
      base = numpy.zeros((100, 100), bool)
      base[
          r.randint(0, 100, size=10), r.randint(0, 100, size=10)
      ] = True
      gt = base.copy()
      gt[r.randint(0, 100, size=5), r.randint(0, 100, size=5)] = True
      test = base.copy()
      test[r.randint(0, 100, size=5), r.randint(0, 100, size=5)] = True
      gt = scipy.ndimage.binary_dilation(gt, numpy.ones((5, 5), bool))
      test = scipy.ndimage.binary_dilation(
          test, numpy.ones((5, 5), bool)
      )
  
      gt_labels, _ = scipy.ndimage.label(gt, numpy.ones((3, 3), bool))
      test_labels, _ = scipy.ndimage.label(
          test, numpy.ones((3, 3), bool)
      )
  
      workspace, module = make_obj_workspace(
          gt_labels,
          test_labels,
          dict(image=numpy.ones(gt_labels.shape)),
          dict(image=numpy.ones(test_labels.shape)),
      )
      module.run(workspace)
  
      measurements = workspace.measurements
      mname = "_".join(
          (
              cellprofiler.modules.measureobjectoverlap.C_IMAGE_OVERLAP,
              cellprofiler.modules.measureobjectoverlap.FTR_RAND_INDEX,
              GROUND_TRUTH_OBJ,
              ID_OBJ,
          )
      )
      expected_rand_index = measurements.get_current_image_measurement(
          mname
      )
      rand_index = measurements.get_current_image_measurement(mname)
      assert round(abs(rand_index - expected_rand_index), 7) == 0
      mname = "_".join(
          (
              cellprofiler.modules.measureobjectoverlap.C_IMAGE_OVERLAP,
              cellprofiler.modules.measureobjectoverlap.FTR_ADJUSTED_RAND_INDEX,
              GROUND_TRUTH_OBJ,
              ID_OBJ,
          )
      )
      adjusted_rand_index = measurements.get_current_image_measurement(
          mname
      )
  
file_path: CellProfiler/tests/frontend/modules/test_measureobjectoverlap.py
imports: import numpy
  import numpy.random
  import scipy.ndimage
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler_core.module
  from cellprofiler_core.constants.measurement import COLTYPE_FLOAT
  import cellprofiler.modules.measureobjectoverlap
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.preferences
  import cellprofiler_core.workspace
label_desc: Use image node_id 6 for calling a global function with example usage: test_test_objects_rand_index() without return types