menpo/shape/graph.py
def from_mask(self, mask):
        """
        A 1D boolean array with the same number of elements as the number of
        points in the PointDirectedGraph. This is then broadcast across the
        dimensions of the PointDirectedGraph and returns a new
        PointDirectedGraph containing only those points that were ``True`` in
        the mask.

        Parameters
        ----------
        mask : ``(n_points,)`` `ndarray`
            1D array of booleans

        Returns
        -------
        pointgraph : :map:`PointDirectedGraph`
            A new pointgraph that has been masked.

        Raises
        ------
        ValueError
            Mask must have same number of points as pointgraph.
        """
        if mask.shape[0] != self.n_points:
            raise ValueError('Mask must be a 1D boolean array of the same '
                             'number of entries as points in this PointTree.')

        pt = self.copy()
        if np.all(mask):  # Shortcut for all true masks
            return pt
        else:
            masked_adj = mask_adjacency_array_tree(
                mask, pt.adjacency_array, pt.adjacency_list,
                pt.predecessors_list, pt.root_vertex)
            if len(masked_adj) == 0:
                raise ValueError('The provided mask deletes all edges.')
            pt.adjacency_array = reindex_adjacency_array(masked_adj)
            pt.points = pt.points[mask, :]
            pt.adjacency_list = pt._get_adjacency_list()
            pt.predecessors_list = pt._get_predecessors_list()
            return pt

        A 1D boolean array with the same number of elements as the number of
        points in the PointDirectedGraph. This is then broadcast across the
        dimensions of the PointDirectedGraph and returns a new
        PointDirectedGraph containing only those points that were ``True`` in
        the mask.

        Parameters
        ----------
        mask : ``(n_points,)`` `ndarray`
            1D array of booleans

        Returns
        -------
        pointgraph : :map:`PointDirectedGraph`
            A new pointgraph that has been masked.

        Raises
        ------
        ValueError
            Mask must have same number of points as pointgraph.
        
A 1D boolean array with the same number of elements as the number of
points in the PointDirectedGraph. This is then broadcast across the
dimensions of the PointDirectedGraph and returns a new
PointDirectedGraph containing only those points that were ``True`` in
the mask.

Parameters



Returns

pointgraph : :map:`PointDirectedGraph`
A new pointgraph that has been masked.

Raises

ValueError
Mask must have same number of points as pointgraph.
A 1D boolean array with the same number of elements as the number of points in the PointDirectedGraph . This is then broadcast across the dimensions of the PointDirectedGraph and returns a new PointDirectedGraph containing only those points that were ` ` True ` ` in the mask . Parameters Returns pointgraph : : map : ` PointDirectedGraph ` A new pointgraph that has been masked . Raises ValueError Mask must have same number of points as pointgraph .
def from_mask(self, mask):
        if mask.shape[0] != self.n_points:
            raise ValueError('Mask must be a 1D boolean array of the same '
                             'number of entries as points in this PointTree.')
        pt = self.copy()
        if np.all(mask):  
            return pt
        else:
            masked_adj = mask_adjacency_array_tree(
                mask, pt.adjacency_array, pt.adjacency_list,
                pt.predecessors_list, pt.root_vertex)
            if len(masked_adj) == 0:
                raise ValueError('The provided mask deletes all edges.')
            pt.adjacency_array = reindex_adjacency_array(masked_adj)
            pt.points = pt.points[mask, :]
            pt.adjacency_list = pt._get_adjacency_list()
            pt.predecessors_list = pt._get_predecessors_list()
            return pt
def from_mask ( self , mask ) : if mask . shape [ 0 ] != self . n_points : raise ValueError ( 'Mask must be a 1D boolean array of the same ' 'number of entries as points in this PointTree.' ) pt = self . copy ( ) if np . all ( mask ) : return pt else : masked_adj = mask_adjacency_array_tree ( mask , pt . adjacency_array , pt . adjacency_list , pt . predecessors_list , pt . root_vertex ) if len ( masked_adj ) == 0 : raise ValueError ( 'The provided mask deletes all edges.' ) pt . adjacency_array = reindex_adjacency_array ( masked_adj ) pt . points = pt . points [ mask , : ] pt . adjacency_list = pt . _get_adjacency_list ( ) pt . predecessors_list = pt . _get_predecessors_list ( ) return pt
A 1D boolean array with the same number of elements as the number of
points in the PointDirectedGraph.
A 1D boolean array with the same number of elements as the number of points in the PointDirectedGraph .
"""
        A 1D boolean array with the same number of elements as the number of
        points in the PointDirectedGraph. This is then broadcast across the
        dimensions of the PointDirectedGraph and returns a new
        PointDirectedGraph containing only those points that were ``True`` in
        the mask.

        Parameters
        ----------
        mask : ``(n_points,)`` `ndarray`
            1D array of booleans

        Returns
        -------
        pointgraph : :map:`PointDirectedGraph`
            A new pointgraph that has been masked.

        Raises
        ------
        ValueError
            Mask must have same number of points as pointgraph.
        """ # Shortcut for all true masks
self
mask