def test_parse_integers(): """ test main :return: """ print(gui_helper.parse_integers('3, 4, 5')) print(gui_helper.parse_integers('3:5, 4:10, 19')) try: int_list = gui_helper.parse_integers('3.2, 4') except RuntimeError as run_err: print(run_err) else: raise AssertionError('Shall be failed but get {0}'.format(int_list))
def plot_diff_data(self, plot_model=True): """ plot diffraction data :return: """ # gather the information try: scan_log_index_list = parse_integers(str(self.parent.ui.lineEdit_listSubRuns.text())) except RuntimeError: pop_message(self, "Unable to parse the string", message_type='error') return if len(scan_log_index_list) == 0: pop_message(self, 'There is not scan-log index input', 'error') # possibly clean the previous # keep_prev = self.ui.checkBox_keepPrevPlot.isChecked() # if keep_prev is False: self.parent._ui_graphicsView_fitSetup.reset_viewer() if len(scan_log_index_list) == 1: self.plot_scan(value=np.int(scan_log_index_list[0])) return # get data and plot err_msg = '' plot_model = len(scan_log_index_list) == 1 and plot_model for scan_log_index in scan_log_index_list: try: self.plot_diff_and_fitted_data(scan_log_index, plot_model) except RuntimeError as run_err: err_msg += '{0}\n'.format(run_err) if len(err_msg) > 0: pop_message(self, err_msg, message_type='error')
def list_subruns_2dplot(self): raw_input = str(self.parent.ui.lineEdit_subruns_2dplot.text()) o_gui = GuiUtilities(parent=self.parent) try: parse_input = parse_integers(raw_input) o_gui.make_visible_listsubruns_warning(False) except RuntimeError: o_gui.make_visible_listsubruns_warning(True) return parse_input
def parse_sub_runs(self): """ Parse sub run numbers specified in lineEdit_scanNumbers :return: List (of integers) or None """ int_string_list = str(self.parent.ui.lineEdit_scanNumbers.text()).strip() if len(int_string_list) == 0 or not self.parent.ui.fit_selected.isChecked(): sub_run_list = None # not set and thus default for all else: sub_run_list = parse_integers(int_string_list) return sub_run_list