docstr: Check centroid-centroid distance calculation
docstr_tok: ["Check","centroid-centroid","distance","calculation"]
code: def test_04_01_distance_centroids(self):
      """Check centroid-centroid distance calculation"""
      i, j = numpy.mgrid[0:14, 0:30]
      parent_labels = (i >= 7) * 1 + (j >= 15) * 2 + 1
      # Centers should be at i=3 and j=7
      parent_centers = numpy.array(
          [[3, 7], [10, 7], [3, 22], [10, 22]], float
      )
      child_labels = numpy.zeros(i.shape)
      numpy.random.seed(0)
      # Take 12 random points and label them
      child_centers = numpy.random.permutation(numpy.prod(i.shape))[:12]
      child_centers = numpy.vstack(
          (i.flatten()[child_centers], j.flatten()[child_centers])
      )
      child_labels[child_centers[0], child_centers[1]] = numpy.arange(
          1, 13
      )
      parent_indexes = (
          parent_labels[child_centers[0], child_centers[1]] - 1
      )
      expected = numpy.sqrt(
          numpy.sum(
              (
                  parent_centers[parent_indexes, :]
                  - child_centers.transpose()
              )
              ** 2,
              1,
          )
      )
  
      workspace, module = self.make_workspace(
          parent_labels, child_labels
      )
      self.assertTrue(
          isinstance(module, cellprofiler.modules.relateobjects.Relate)
      )
      module.find_parent_child_distances.value = (
          cellprofiler.modules.relateobjects.D_BOTH
      )
      module.run(workspace)
      self.features_and_columns_match(workspace)
      meas = workspace.measurements
      v = meas.get_current_measurement(
          CHILD_OBJECTS,
          cellprofiler.modules.relateobjects.FF_CENTROID
          % PARENT_OBJECTS,
      )
      assert v.shape[0] == 12
      assert numpy.all(numpy.abs(v - expected) < 0.0001)
  
imports: import numpy
  import unittest
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler_core.module
  from cellprofiler_core.constants.measurement import C_PARENT, GROUP_NUMBER, GROUP_INDEX, COLTYPE_FLOAT, COLTYPE_INTEGER, M_LOCATION_CENTER_X, M_LOCATION_CENTER_Y, FF_PARENT
  import cellprofiler.modules.relateobjects
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.preferences
  import cellprofiler_core.workspace
label_desc: Use image node_id 10 for calling the TestRelateObjects obj's underlying member method code with example usage: obj.test_04_01_distance_centroids() without return types