示例#1
0
    def reload_lme4(self, install=False):
        """Reload information about lme4, optionally installing it"""
        # set the binary
        binary = self.lme4_rpath.text()
        if pathlib.Path(binary).is_file():
            try:
                rsetup.set_r_path(binary)
            except RUnavailableError as exc:
                QtWidgets.QMessageBox.information(
                    self, "No compatible R version found",
                    "The R/lme4 functionality is not available.\n\n" +
                    f"{exc.__class__.__name__}: {exc}")

        # check lme4 package status
        if not rsetup.has_r():
            r_version = "unknown"
            lme4_st = "unknown"
        else:
            r_version = rsetup.get_r_version()
            if rsetup.has_lme4():
                lme4_st = "installed"
            else:
                lme4_st = "not installed"

        if install and lme4_st == "not installed":
            self.setEnabled(False)
            rsetup.install_lme4()
            self.setEnabled(True)
            # update interface with installed lme4
            self.reload_lme4(install=False)
        else:
            # update user interface
            self.pushButton_lme4_install.setVisible(lme4_st == "not installed")
            self.label_r_version.setText(r_version)
            self.label_lme4_installed.setText(lme4_st)
    def reload_lme4(self, install=False):
        """Reload information about lme4, optionally installing it"""
        # set the binary
        binary = self.lme4_rpath.text()
        if pathlib.Path(binary).is_file():
            rsetup.set_r_path(binary)
        # check lme4 package status
        if not rsetup.has_r():
            r_version = "unknown"
            lme4_st = "unknown"
        else:
            r_version = rsetup.get_r_version()
            if rsetup.has_lme4():
                lme4_st = "installed"
            else:
                lme4_st = "not installed"

        if install and lme4_st == "not installed":
            self.setEnabled(False)
            rsetup.install_lme4()
            self.setEnabled(True)
            # update interface with installed lme4
            self.reload_lme4(install=False)
        else:
            # update user interface
            self.pushButton_lme4_install.setVisible(lme4_st == "not installed")
            self.label_r_version.setText(r_version)
            self.label_lme4_installed.setText(lme4_st)
示例#3
0
    def __init__(self, parent, *args, **kwargs):
        QtWidgets.QWidget.__init__(self, parent=parent, *args, **kwargs)
        path_ui = pkg_resources.resource_filename("shapeout2.gui",
                                                  "preferences.ui")
        uic.loadUi(path_ui, self)
        self.settings = QtCore.QSettings()
        self.parent = parent

        # Get default R path
        if RPY2_AVAILABLE and rsetup.has_r():
            rdefault = rsetup.get_r_path()
        else:
            rdefault = ""

        # disable R settings
        self.tab_r.setEnabled(RPY2_AVAILABLE)

        #: configuration keys, corresponding widgets, and defaults
        self.config_pairs = [
            ["advanced/developer mode", self.advanced_developer_mode, "0"],
            ["check for updates", self.general_check_for_updates, "1"],
            ["dcor/api key", self.dcor_api_key, ""],
            ["dcor/servers", self.dcor_servers, ["dcor.mpl.mpg.de"]],
            ["dcor/use ssl", self.dcor_use_ssl, "1"],
            ["lme4/r path", self.lme4_rpath, rdefault],
        ]

        # extensions
        store_path = os_path.join(
            QStandardPaths.writableLocation(QStandardPaths.AppDataLocation),
            "extensions")
        self.extensions = ExtensionManager(store_path)

        self.reload()

        # signals
        self.btn_apply = self.buttonBox.button(
            QtWidgets.QDialogButtonBox.Apply)
        self.btn_apply.clicked.connect(self.on_settings_apply)
        self.btn_cancel = self.buttonBox.button(
            QtWidgets.QDialogButtonBox.Cancel)
        self.btn_ok = self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok)
        self.btn_ok.clicked.connect(self.on_settings_apply)
        self.btn_restore = self.buttonBox.button(
            QtWidgets.QDialogButtonBox.RestoreDefaults)
        self.btn_restore.clicked.connect(self.on_settings_restore)
        # extension buttons
        self.checkBox_ext_enabled.clicked.connect(self.on_ext_enabled)
        self.pushButton_ext_load.clicked.connect(self.on_ext_load)
        self.pushButton_ext_remove.clicked.connect(self.on_ext_remove)
        self.listWidget_ext.currentRowChanged.connect(self.on_ext_selected)
        self.listWidget_ext.itemChanged.connect(self.on_ext_modified)
        # lme4 buttons
        self.pushButton_lme4_install.clicked.connect(self.on_lme4_install)
        self.pushButton_lme4_search.clicked.connect(self.on_lme4_search_r)
        # tab changed
        self.tabWidget.currentChanged.connect(self.on_tab_changed)
示例#4
0
 def on_action_compute_significance(self):
     # check that R is available
     if rsetup.has_r():
         dlg = compute.ComputeSignificance(self, pipeline=self.pipeline)
         dlg.exec()
     else:
         QtWidgets.QMessageBox.critical(
             self, "R not found!",
             "The R executable was not found by rpy2. Please add it " +
             "to the PATH variable or define it manually in the " +
             "Shape-Out preferences.")
示例#5
0
    def __init__(self, parent, *args, **kwargs):
        QtWidgets.QWidget.__init__(self, parent=parent, *args, **kwargs)
        path_ui = pkg_resources.resource_filename("shapeout2.gui",
                                                  "preferences.ui")
        uic.loadUi(path_ui, self)
        self.settings = QtCore.QSettings()
        self.parent = parent

        # Get default R path
        if RPY2_AVAILABLE and rsetup.has_r():
            rdefault = rsetup.get_r_path()
        else:
            rdefault = ""

        # disable R settings
        self.tab_r.setEnabled(RPY2_AVAILABLE)

        #: configuration keys, corresponding widgets, and defaults
        self.config_pairs = [
            ["advanced/developer mode", self.advanced_developer_mode, 0],
            [
                "advanced/check pyqtgraph version",
                self.advanced_check_pyqtgraph_version, 1
            ],
            ["check for updates", self.general_check_for_updates, 1],
            ["dcor/api key", self.dcor_api_key, ""],
            ["dcor/servers", self.dcor_servers, ["dcor.mpl.mpg.de"]],
            ["dcor/use ssl", self.dcor_use_ssl, 1],
            ["lme4/r path", self.lme4_rpath, rdefault],
        ]
        self.reload()

        # signals
        btn_apply = self.buttonBox.button(QtWidgets.QDialogButtonBox.Apply)
        btn_apply.clicked.connect(self.on_apply)
        btn_ok = self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok)
        btn_ok.clicked.connect(self.on_apply)
        btn_restore = self.buttonBox.button(
            QtWidgets.QDialogButtonBox.RestoreDefaults)
        btn_restore.clicked.connect(self.on_restore)
        # lme4 buttons
        self.pushButton_lme4_install.clicked.connect(self.on_lme4_install)
        self.pushButton_lme4_search.clicked.connect(self.on_lme4_search_r)
示例#6
0
def test_basic_setup():
    assert rsetup.has_r()
    rsetup.install_lme4()
    assert rsetup.has_lme4()