(self)
Commit/send the current selected row/column selection.
Commit/send the current selected row/column selection.
Commit / send the current selected row / column selection .
def commit(self):
        """
        Commit/send the current selected row/column selection.
        """
        selected_data = table = rowsel = None
        view = self.tabs.currentWidget()
        if view and view.model() is not None:
            model = self._get_model(view)
            table = model.source  # The input data table

            # Selections of individual instances are not implemented
            # for SqlTables
            if isinstance(table, SqlTable):
                self.Outputs.selected_data.send(selected_data)
                self.Outputs.annotated_data.send(None)
                return

            rowsel, colsel = self.get_selection(view)
            self.selected_rows, self.selected_cols = rowsel, colsel

            domain = table.domain

            if len(colsel) < len(domain.variables) + len(domain.metas):
                # only a subset of the columns is selected
                allvars = domain.class_vars + domain.metas + domain.attributes
                columns = [(c, model.headerData(c, Qt.Horizontal,
                                                TableModel.DomainRole))
                           for c in colsel]
                assert all(role is not None for _, role in columns)

                def select_vars(role):
                    """select variables for role (TableModel.DomainRole)"""
                    return [allvars[c] for c, r in columns if r == role]

                attrs = select_vars(TableModel.Attribute)
                if attrs and issparse(table.X):
                    # for sparse data you can only select all attributes
                    attrs = table.domain.attributes
                class_vars = select_vars(TableModel.ClassVar)
                metas = select_vars(TableModel.Meta)
                domain = Orange.data.Domain(attrs, class_vars, metas)

            # Send all data by default
            if not rowsel:
                selected_data = table
            else:
                selected_data = table.from_table(domain, table, rowsel)

        self.Outputs.selected_data.send(selected_data)
        self.Outputs.annotated_data.send(create_annotated_table(table, rowsel))
def commit ( self ) : selected_data = table = rowsel = None view = self . tabs . currentWidget ( ) if view and view . model ( ) is not None : model = self . _get_model ( view ) table = model . source # The input data table # Selections of individual instances are not implemented # for SqlTables if isinstance ( table , SqlTable ) : self . Outputs . selected_data . send ( selected_data ) self . Outputs . annotated_data . send ( None ) return rowsel , colsel = self . get_selection ( view ) self . selected_rows , self . selected_cols = rowsel , colsel domain = table . domain if len ( colsel ) < len ( domain . variables ) + len ( domain . metas ) : # only a subset of the columns is selected allvars = domain . class_vars + domain . metas + domain . attributes columns = [ ( c , model . headerData ( c , Qt . Horizontal , TableModel . DomainRole ) ) for c in colsel ] assert all ( role is not None for _ , role in columns ) def select_vars ( role ) : """select variables for role (TableModel.DomainRole)""" return [ allvars [ c ] for c , r in columns if r == role ] attrs = select_vars ( TableModel . Attribute ) if attrs and issparse ( table . X ) : # for sparse data you can only select all attributes attrs = table . domain . attributes class_vars = select_vars ( TableModel . ClassVar ) metas = select_vars ( TableModel . Meta ) domain = Orange . data . Domain ( attrs , class_vars , metas ) # Send all data by default if not rowsel : selected_data = table else : selected_data = table . from_table ( domain , table , rowsel ) self . Outputs . selected_data . send ( selected_data ) self . Outputs . annotated_data . send ( create_annotated_table ( table , rowsel ) )