(cls, mask)
return cls(data=[(nz_row[i], nz_col[i]) for i in range(len(nz_row))], label_size=mask.shape[1])
Construct a MultiLabelIndexCollection object by providing a
        2d array whose shape should be the same as the matrix shape.

        Parameters
        ----------
        mask: {list, np.ndarray}
            The 2d mask matrix of elements.
            There must be only 1 and 0 in the matrix, in which,
            1 means the corresponding element is known, and will be
            added to the MultiLabelIndexCollection container.
            Otherwise, it will be cheated as an unknown element.

        Examples
        --------
        >>> import numpy as np
        >>> mask = np.asarray([
            [0, 1],
            [1, 0],
            [1, 0]
        ]) # 3 rows, 2 lines
        >>> mi = MultiLabelIndexCollection.construct_by_element_mask(mask=mask)
        >>> print(mi)
        {(0, 1), (2, 0), (1, 0)}
Construct a MultiLabelIndexCollection object by providing a
        2d array whose shape should be the same as the matrix shape.
Construct a MultiLabelIndexCollection object by providing a 2d array whose shape should be the same as the matrix shape .
def construct_by_element_mask(cls, mask):
        """Construct a MultiLabelIndexCollection object by providing a
        2d array whose shape should be the same as the matrix shape.

        Parameters
        ----------
        mask: {list, np.ndarray}
            The 2d mask matrix of elements.
            There must be only 1 and 0 in the matrix, in which,
            1 means the corresponding element is known, and will be
            added to the MultiLabelIndexCollection container.
            Otherwise, it will be cheated as an unknown element.

        Examples
        --------
        >>> import numpy as np
        >>> mask = np.asarray([
            [0, 1],
            [1, 0],
            [1, 0]
        ]) # 3 rows, 2 lines
        >>> mi = MultiLabelIndexCollection.construct_by_element_mask(mask=mask)
        >>> print(mi)
        {(0, 1), (2, 0), (1, 0)}

        """
        mask = np.asarray(mask)
        ue = np.unique(mask)
        if not (len(mask.shape) == 2 and len(ue) == 2 and 0 in ue and 1 in ue):
            raise ValueError("The mask matrix should be a 2d array, and there must be only "
                             "1 and 0 in the matrix, in which, 1 means the corresponding "
                             "element is known, and will be added to the MultiLabelIndexCollection container.")

        nz_row, nz_col = np.nonzero(mask)
        return cls(data=[(nz_row[i], nz_col[i]) for i in range(len(nz_row))], label_size=mask.shape[1])
def construct_by_element_mask ( cls , mask ) : mask = np . asarray ( mask ) ue = np . unique ( mask ) if not ( len ( mask . shape ) == 2 and len ( ue ) == 2 and 0 in ue and 1 in ue ) : raise ValueError ( "The mask matrix should be a 2d array, and there must be only " "1 and 0 in the matrix, in which, 1 means the corresponding " "element is known, and will be added to the MultiLabelIndexCollection container." ) nz_row , nz_col = np . nonzero ( mask ) return cls ( data = [ ( nz_row [ i ] , nz_col [ i ] ) for i in range ( len ( nz_row ) ) ] , label_size = mask . shape [ 1 ] )