(self)
Commit/send the current selection to the output.
Commit/send the current selection to the output.
Commit / send the current selection to the output .
def commit(self):
        """
        Commit/send the current selection to the output.
        """
        selected = indices = data = None
        if self.data is not None:
            selectedmask = np.full(len(self.data), False, dtype=bool)
            if self._silplot is not None:
                indices = self._silplot.selection()
                assert (np.diff(indices) > 0).all(), "strictly increasing"
                if self._mask is not None:
                    # pylint: disable=invalid-unary-operand-type
                    indices = np.flatnonzero(~self._mask)[indices]
                selectedmask[indices] = True

            if self._mask is not None:
                scores = np.full(shape=selectedmask.shape,
                                 fill_value=np.nan)
                # pylint: disable=invalid-unary-operand-type
                scores[~self._mask] = self._silhouette
            else:
                scores = self._silhouette

            var = self.cluster_var_model[self.cluster_var_idx]

            domain = self.data.domain
            proposed = "Silhouette ({})".format(escape(var.name))
            names = [var.name for var in itertools.chain(domain.attributes,
                                                         domain.class_vars,
                                                         domain.metas)]
            unique = get_unique_names(names, proposed)
            silhouette_var = Orange.data.ContinuousVariable(unique)
            domain = Orange.data.Domain(
                domain.attributes,
                domain.class_vars,
                domain.metas + (silhouette_var, ))

            if np.count_nonzero(selectedmask):
                selected = self.data.from_table(
                    domain, self.data, np.flatnonzero(selectedmask))

            if selected is not None:
                with selected.unlocked(selected.metas):
                    selected[:, silhouette_var] = np.c_[scores[selectedmask]]

            data = self.data.transform(domain)
            with data.unlocked(data.metas):
                data[:, silhouette_var] = np.c_[scores]

        self.Outputs.selected_data.send(selected)
        self.Outputs.annotated_data.send(create_annotated_table(data, indices))
def commit ( self ) : selected = indices = data = None if self . data is not None : selectedmask = np . full ( len ( self . data ) , False , dtype = bool ) if self . _silplot is not None : indices = self . _silplot . selection ( ) assert ( np . diff ( indices ) > 0 ) . all ( ) , "strictly increasing" if self . _mask is not None : # pylint: disable=invalid-unary-operand-type indices = np . flatnonzero ( ~ self . _mask ) [ indices ] selectedmask [ indices ] = True if self . _mask is not None : scores = np . full ( shape = selectedmask . shape , fill_value = np . nan ) # pylint: disable=invalid-unary-operand-type scores [ ~ self . _mask ] = self . _silhouette else : scores = self . _silhouette var = self . cluster_var_model [ self . cluster_var_idx ] domain = self . data . domain proposed = "Silhouette ({})" . format ( escape ( var . name ) ) names = [ var . name for var in itertools . chain ( domain . attributes , domain . class_vars , domain . metas ) ] unique = get_unique_names ( names , proposed ) silhouette_var = Orange . data . ContinuousVariable ( unique ) domain = Orange . data . Domain ( domain . attributes , domain . class_vars , domain . metas + ( silhouette_var , ) ) if np . count_nonzero ( selectedmask ) : selected = self . data . from_table ( domain , self . data , np . flatnonzero ( selectedmask ) ) if selected is not None : with selected . unlocked ( selected . metas ) : selected [ : , silhouette_var ] = np . c_ [ scores [ selectedmask ] ] data = self . data . transform ( domain ) with data . unlocked ( data . metas ) : data [ : , silhouette_var ] = np . c_ [ scores ] self . Outputs . selected_data . send ( selected ) self . Outputs . annotated_data . send ( create_annotated_table ( data , indices ) )