Ejemplo n.º 1
0
    def on_computed(self, future):
        assert self.thread() is QThread.currentThread()
        assert future.done()

        self._task = None
        self.progressBarFinished()

        df = future.result()
        # Only retain "significant" p-values
        df = df[df[CORRECTED_LABEL] < .2]

        columns = [var.name for var in df.index.name] + list(df.columns)
        lst = [list(i) + list(j)
               for i, j in zip(df.index, df.values)]

        results_table = table_from_frame(pd.DataFrame(lst, columns=columns),
                                         force_nominal=True)
        results_table.name = 'Significant Groups'
        self.Outputs.results.send(results_table)

        self.view.set_vars(list(df.index.name))
        self.model.setHorizontalHeaderLabels(columns, len(df.index.name))
        self.model.wrap(lst)
        self.view.sortByColumn(len(columns) - 1, Qt.AscendingOrder)

        self.Information.nothing_significant(shown=not lst)
        self.btn_compute.setEnabled(True)
Ejemplo n.º 2
0
    def download_complete(self, future):
        assert self.thread() is QThread.currentThread()
        assert future.done()

        self._task = None
        self.progressBarFinished()
        self.setCursor(Qt.ArrowCursor)
        self.btn_download.setText(self.LABEL_DOWNLOAD)
        self.btn_connect.setEnabled(True)
        self.Information.fetching_node_info.clear()

        table = None
        try:
            df = future.result()  # type: pd.DataFrame
        except self.Cancelled:
            pass
        except Exception as e:
            log.exception("Failed to download data for nodes")
            self.Error.fetching_node_info_failed(e)
        else:
            if df.shape[0] > self.sample_size:
                df = df.sample(self.sample_size)
            table = table_from_frame(df)

        self.Outputs.data.send(table)
Ejemplo n.º 3
0
        # 2d array of (n-2)d-list fields
        x2d = np.empty(x.shape[:2], dtype=object)
        x2d[:] = x.tolist()
        return x2d

    x = _to2d(x)
    # 2d or str arrays etc. not supported
    if x is None or not is_numeric_dtype(x):
        return None
    return Table.from_numpy(None, x)


# Mapping of Jupyter types to callable conversions to Orange Table
VALID_DATA_TYPES = {
    pd.DataFrame: table_from_frame,
    pd.Series: lambda s: table_from_frame(s.to_frame()),
    np.ndarray: _table_from_numpy,
    Table: lambda x: x,
}


class OWIPythonConnector(widget.OWWidget):
    name = 'IPython Connector'
    description = 'Import objects stored with IPython/Jupyter %store magic command.'
    icon = 'icons/IPythonConnector.svg'
    priority = 100

    class Outputs(widget.OWWidget.Outputs):
        data = widget.Output('Data', Table)
        object = widget.Output('Raw Object', object)