# Buggy code
def validate_module(self, pipeline):
    """Validate the module's settings

    Relate will complain if the children and parents are related
    by a prior module or if a step-parent is named twice"""
    for module in pipeline.modules():
        if module == self:
            break

        parent_features = module.get_measurements(
            pipeline, self.sub_object_name.value, "Parent"
        )

        if self.parent_name.value in parent_features:
            raise cellprofiler.setting.ValidationError(
                "{} and {} were related by the {} module".format(
                    self.sub_object_name.value,
                    self.parent_name.value,
                    module.module_name,
                ),
                self.parent_name,
            )

    if self.has_step_parents and self.wants_step_parent_distances:
        step_parents = set()
        for group in self.step_parent_names:
            if group.step_parent_name.value in step_parents:
                raise cellprofiler.setting.ValidationError(
                    "{} has already been chosen".format(group.step_parent_name.value),
                    group.step_parent_name,
                )

            step_parents.add(group.step_parent_name.value)


# 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 validate_module(self, pipeline):
    """Validate the module's settings

    Relate will complain if the children and parents are related
    by a prior module or if a step-parent is named twice"""
    for module in pipeline.modules():
        if module == self:
            break

        parent_features = module.get_measurements(pipeline, self.y_name.value, "Parent")

        if self.x_name.value in parent_features:
            raise cellprofiler.setting.ValidationError(
                "{} and {} were related by the {} module".format(
                    self.y_name.value, self.x_name.value, module.module_name
                ),
                self.x_name,
            )

    if self.has_step_parents and self.wants_step_parent_distances:
        step_parents = set()
        for group in self.step_parent_names:
            if group.step_parent_name.value in step_parents:
                raise cellprofiler.setting.ValidationError(
                    "{} has already been chosen".format(group.step_parent_name.value),
                    group.step_parent_name,
                )

            step_parents.add(group.step_parent_name.value)