# Buggy code
def calculate_centroid_distances(self, workspace, parent_name):
    """Calculate the centroid-centroid distance between parent & child"""
    meas = workspace.measurements

    sub_object_name = self.sub_object_name.value

    parents = workspace.object_set.get_objects(parent_name)

    children = workspace.object_set.get_objects(sub_object_name)

    parents_of = self.get_parents_of(workspace, parent_name)

    pcenters = centrosome.cpmorphology.centers_of_labels(parents.segmented).transpose()

    ccenters = centrosome.cpmorphology.centers_of_labels(children.segmented).transpose()

    if pcenters.shape[0] == 0 or ccenters.shape[0] == 0:
        dist = numpy.array([numpy.NaN] * len(parents_of))
    else:
        #
        # Make indexing of parents_of be same as pcenters
        #
        parents_of = parents_of - 1

        mask = (parents_of != -1) | (parents_of > pcenters.shape[0])

        dist = numpy.array([numpy.NaN] * ccenters.shape[0])

        dist[mask] = numpy.sqrt(
            numpy.sum((ccenters[mask, :] - pcenters[parents_of[mask], :]) ** 2, 1)
        )

    meas.add_measurement(sub_object_name, FF_CENTROID % parent_name, dist)


# Traceback (ValueError)
Traceback (most recent call last):
File "C:\Users\brayma2\Desktop\GitHub\CellProfiler\cellprofiler\gui\pipelinecontroller.py", line 2844, in do_step
self.__pipeline.run_module(module, workspace)
File "C:\Users\brayma2\Desktop\GitHub\CellProfiler\cellprofiler\pipeline.py", line 2108, in run_module
module.run(workspace)
File "C:\Users\brayma2\Desktop\GitHub\CellProfiler\cellprofiler\modules\relateobjects.py", line 252, in run
self.calculate_centroid_distances(workspace, parent_name)
File "C:\Users\brayma2\Desktop\GitHub\CellProfiler\cellprofiler\modules\relateobjects.py", line 336, in calculate_centroid_distances
parents_of = self.get_parents_of(workspace, parent_name)
File "C:\Users\brayma2\Desktop\GitHub\CellProfiler\cellprofiler\modules\relateobjects.py", line 475, in get_parents_of
reverse_lookup_len = max(np.max(primary_parents_of) + 1,
File "C:\Python27\lib\site-packages\numpy\core\fromnumeric.py", line 2263, in amax
out=out, keepdims=keepdims)
File "C:\Python27\lib\site-packages\numpy\core\_methods.py", line 26, in _amax
return umr_maximum(a, axis, None, out, keepdims)
ValueError: zero-size array to reduction operation maximum which has no identity

# Fixed code
def calculate_centroid_distances(self, workspace, parent_name):
    """Calculate the centroid-centroid distance between parent & child"""
    meas = workspace.measurements

    sub_object_name = self.y_name.value

    parents = workspace.object_set.get_objects(parent_name)

    children = workspace.object_set.get_objects(sub_object_name)

    parents_of = self.get_parents_of(workspace, parent_name)

    pcenters = parents.center_of_mass()

    ccenters = children.center_of_mass()

    if pcenters.shape[0] == 0 or ccenters.shape[0] == 0:
        dist = numpy.array([numpy.NaN] * len(parents_of))
    else:
        #
        # Make indexing of parents_of be same as pcenters
        #
        parents_of = parents_of - 1

        mask = (parents_of != -1) | (parents_of > pcenters.shape[0])

        dist = numpy.array([numpy.NaN] * ccenters.shape[0])

        dist[mask] = numpy.sqrt(
            numpy.sum((ccenters[mask, :] - pcenters[parents_of[mask], :]) ** 2, 1)
        )

    meas.add_measurement(sub_object_name, FF_CENTROID % parent_name, dist)