def _upper_set_cluster(self, threshold, form='mass'):

        ## identify upper level points and the nodes active at the cut
        if form == 'mass':
            density_level = self._mass_to_density(mass=threshold)
            return self._upper_set_cluster(threshold=density_level,
                                           form='density')

        else:
            upper_level_set = _np.where(_np.array(self.density) > threshold)[0]
            active_nodes = [k for k, v in self.nodes.iteritems()
                            if (v.start_level <= threshold and
                                v.end_level > threshold)]

            ## find intersection between upper set points and each active
            #  component
            points = []
            cluster = []

            for c in active_nodes:
                cluster_mask = _np.in1d(upper_level_set,
                                        list(self.nodes[c].members))
                cluster_pts = upper_level_set[cluster_mask]
                points.extend(cluster_pts)
                cluster += ([c] * len(cluster_pts))

            labels = _np.array([points, cluster], dtype=_np.int).T
            return labels
Given expressions for start, stop, and step of an iteration range
dataset/ETHPy150Open CoAxLab/DeBaCl/debacl/level_set_tree.py/LevelSetTree._upper_set_cluster--crossover with--dataset/ETHPy150Open iskandr/parakeet/parakeet/transforms/lower_array_operators.py/LowerArrayOperators.mk_range_fn