Ejemplo n.º 1
0
    def test_proper_name_argument(self):

        argument = ProperNameArgument()

        self.assertTrue(argument.validate("NAME"))
        self.assertTrue(argument.validate("__NAME__"))
        self.assertTrue(argument.validate("<NAME>"))
        self.assertTrue(argument.validate("-NAME-"))

        self.assertFalse(argument.validate("-NA ME-"))
        self.assertFalse(argument.validate("NAME*"))
Ejemplo n.º 2
0
    def __init__(self, ert: EnKFMain, notifier: ErtNotifier):
        super().__init__(EnsembleSmoother)
        self.ert = ert
        facade = LibresFacade(ert)
        layout = QFormLayout()

        self._case_selector = CaseSelector(facade, notifier)
        layout.addRow("Current case:", self._case_selector)

        run_path_label = QLabel(f"<b>{facade.run_path}</b>")
        addHelpToWidget(run_path_label, "config/simulation/runpath")
        layout.addRow("Runpath:", run_path_label)

        number_of_realizations_label = QLabel(
            f"<b>{facade.get_ensemble_size()}</b>")
        addHelpToWidget(number_of_realizations_label,
                        "config/ensemble/num_realizations")
        layout.addRow(QLabel("Number of realizations:"),
                      number_of_realizations_label)

        self._target_case_model = TargetCaseModel(facade, notifier)
        self._target_case_field = StringBox(self._target_case_model,
                                            "config/simulation/target_case")
        self._target_case_field.setValidator(ProperNameArgument())
        layout.addRow("Target case:", self._target_case_field)

        self._analysis_module_edit = AnalysisModuleEdit(
            facade,
            module_name=EnsembleSmootherPanel.analysis_module_name,
            help_link="config/analysis/analysis_module",
        )
        layout.addRow("Analysis module:", self._analysis_module_edit)

        active_realizations_model = ActiveRealizationsModel(facade)
        self._active_realizations_field = StringBox(
            active_realizations_model, "config/simulation/active_realizations")
        self._active_realizations_field.setValidator(
            RangeStringArgument(facade.get_ensemble_size()))
        layout.addRow("Active realizations", self._active_realizations_field)

        self.setLayout(layout)

        self._target_case_field.getValidationSupport(
        ).validationChanged.connect(self.simulationConfigurationChanged)
        self._active_realizations_field.getValidationSupport(
        ).validationChanged.connect(  # noqa
            self.simulationConfigurationChanged)
        self._case_selector.currentIndexChanged.connect(
            self._realizations_from_fs)

        self._realizations_from_fs()  # update with the current case
Ejemplo n.º 3
0
    def __init__(self):
        SimulationConfigPanel.__init__(self, EnsembleSmoother)

        layout = QFormLayout()

        self._case_selector = CaseSelector()
        layout.addRow("Current case:", self._case_selector)

        run_path_label = QLabel("<b>%s</b>" % getRunPath())
        addHelpToWidget(run_path_label, "config/simulation/runpath")
        layout.addRow("Runpath:", run_path_label)

        number_of_realizations_label = QLabel("<b>%d</b>" %
                                              getRealizationCount())
        addHelpToWidget(number_of_realizations_label,
                        "config/ensemble/num_realizations")
        layout.addRow(QLabel("Number of realizations:"),
                      number_of_realizations_label)

        self._target_case_model = TargetCaseModel()
        self._target_case_field = StringBox(self._target_case_model,
                                            "config/simulation/target_case")
        self._target_case_field.setValidator(ProperNameArgument())
        layout.addRow("Target case:", self._target_case_field)

        self._analysis_module_selector = AnalysisModuleSelector(
            iterable=False, help_link="config/analysis/analysis_module")
        layout.addRow("Analysis Module:", self._analysis_module_selector)

        active_realizations_model = ActiveRealizationsModel()
        self._active_realizations_field = StringBox(
            active_realizations_model, "config/simulation/active_realizations")
        self._active_realizations_field.setValidator(
            RangeStringArgument(getRealizationCount()))
        layout.addRow("Active realizations", self._active_realizations_field)

        self.setLayout(layout)

        self._target_case_field.getValidationSupport(
        ).validationChanged.connect(self.simulationConfigurationChanged)
        self._active_realizations_field.getValidationSupport(
        ).validationChanged.connect(self.simulationConfigurationChanged)
        self._case_selector.currentIndexChanged.connect(
            self._realizations_from_fs)

        self._realizations_from_fs()  # update with the current case
Ejemplo n.º 4
0
def valid_name(user_input):
    validator = ProperNameArgument()
    validated = validator.validate(user_input)
    if validated.failed():
        strip_error_message_and_raise_exception(validated)
    return user_input