def setUp(self): self.number_of_resamples = 10000 filename = 'flicker.xlsx' self.bootstrapper = None fh = FileHandling() self.data_dict = fh.import_spreadsheet(filename) self.bootstrapper = Bootstrapper(self.data_dict, self.number_of_resamples) self.bootstrapped_dict = self.bootstrapper.bootstrapped_data
def __init__(self): FileHandling.__init__(self, ".settings") self.setings = {} self._setings_file = self.system_path + "\\"+self._settings_name if os.path.isfile(self._setings_file): self.load_settings() else: self.restore_default() self.safe_settings() pass
def setUp(self): self.number_of_resamples = 10000 # import dataset from file filename = 'flicker.xlsx' self.__fh = FileHandling() self.original_data_dict = self.__fh.import_spreadsheet(filename) # resample dataset self.__bootstrapper = Bootstrapper(self.original_data_dict, self.number_of_resamples) #init bootstrap analysis tools self.analysis = BootstrapAnalysis(self.__bootstrapper)
def __init__(self, parent): FileHandling.__init__(self, ".cut") self.Dialog = QtWidgets.QDialog(parent) self.ui = mw.Ui_Dialog() self.ui.setupUi(self.Dialog) self.schnittparameter: model_Schnittparameter.Schnittparameter = None self.new_schnittparameter: model_Schnittparameter.Schnittparameter = None self.ui.pushButton_exportieren.clicked.connect( self.pushButton_exportieren) self.ui.pushButton_Laden.clicked.connect(self.pushButton_Laden) self.ui.buttonBox.accepted.connect(self.accepted) self.ui.buttonBox.rejected.connect(self.rejected) self.Dialog.setFixedSize(self.Dialog.sizeHint())
def __init__(self, parent): FileHandling.__init__(self,".wst") self.Dialog = QtWidgets.QDialog(parent) self.ui = mw.Ui_Dialog() self.ui.setupUi(self.Dialog) self.new_arbeitsschritt: model_Arbeitsschritt.Arbeitsschritt = None self.arbeitsschritt: model_Arbeitsschritt.Arbeitsschritt = None self.guischnittparameter = gui_Schnittparameter.gui_Schnittparameter(self.Dialog) self.ui.buttonBox.accepted.connect(self.accepted) self.ui.buttonBox.rejected.connect(self.rejected) self.ui.pushButton_Schnittparameter.clicked.connect(self.pushButton_Schnittparameter) self.ui.pushButton_Laden.clicked.connect(self.pushButton_Laden) self.ui.pushButton_exportieren.clicked.connect(self.pushButton_exportieren) self.ui.pushButton_Geometrie_Importieren.clicked.connect(self.pushButton_Geometrie_Importieren)
class TestBootstrapAnalysis(TestCase): def setUp(self): self.number_of_resamples = 10000 # import dataset from file filename = 'flicker.xlsx' self.__fh = FileHandling() self.original_data_dict = self.__fh.import_spreadsheet(filename) # resample dataset self.__bootstrapper = Bootstrapper(self.original_data_dict, self.number_of_resamples) #init bootstrap analysis tools self.analysis = BootstrapAnalysis(self.__bootstrapper) def check_keys_in_dict(self, dict): key_count = 0 key_list = [] for key in dict: result_dict = dict[key] for key, values in result_dict.items(): print(key) key_list.append(key) key_count+= 1 return key_list, key_count def test_mean_dictionary_keys(self): """ Tests if the correct number of keys (experiment column names) is contained in the result dict and if the contained keys are identical to the column names. """ mean_dict = self.analysis.get_bootstrapped_mean() key_list, key_count = self.check_keys_in_dict(mean_dict) self.assertEqual(3, key_count) self.assertTrue(sorted(["Brown", "Green", "Blue"]) == sorted(key_list)) def test_median_dictionary_keys(self): """ Tests if the correct number of keys (experiment column names) is contained in the result dict and if the contained keys are identical to the column names. """ median_dict = self.analysis.get_bootstrapped_median() key_list, key_count = self.check_keys_in_dict(median_dict) self.assertEqual(3, key_count) self.assertTrue(sorted(["Brown", "Green", "Blue"]) == sorted(key_list)) def test_SEM(self): """ Tests if the correct number of keys (experiment column names) is contained in the result dict and if the contained keys are identical to the column names. """ sem_dict = self.analysis.get_bootstrapped_median() key_list, key_count = self.check_keys_in_dict(sem_dict) self.assertEqual(3, key_count) self.assertTrue(sorted(["Brown", "Green", "Blue"]) == sorted(key_list))
def __init__(self, parent): FileHandling.__init__(self, ".pro") self.Dialog = QtWidgets.QDialog(parent) self.ui = mw.Ui_Dialog() self.ui.setupUi(self.Dialog) self.new_prozess: model_Prozess.Prozess = None self.prozess: model_Prozess.Prozess = None self.ui.buttonBox.accepted.connect(self.accepted) self.ui.buttonBox.rejected.connect(self.rejected) self.ui.pushButton_Laden.clicked.connect(self.pushButton_Laden) self.ui.pushButton_exportieren.clicked.connect( self.pushButton_exportieren) self.Dialog.setFixedSize(self.Dialog.sizeHint())
class TestBootstrapAnalysis(TestCase): def setUp(self): self.number_of_resamples = 10000 # import dataset from file filename = 'flicker.xlsx' self.__fh = FileHandling() self.original_data_dict = self.__fh.import_spreadsheet(filename) # resample dataset self.__bootstrapper = Bootstrapper(self.original_data_dict, self.number_of_resamples) #init bootstrap analysis tools self.analysis = BootstrapAnalysis(self.__bootstrapper) def check_keys_in_dict(self, dict): key_count = 0 key_list = [] for key in dict: result_dict = dict[key] for key, values in result_dict.items(): print(key) key_list.append(key) key_count += 1 return key_list, key_count def test_mean_dictionary_keys(self): """ Tests if the correct number of keys (experiment column names) is contained in the result dict and if the contained keys are identical to the column names. """ mean_dict = self.analysis.get_bootstrapped_mean() key_list, key_count = self.check_keys_in_dict(mean_dict) self.assertEqual(3, key_count) self.assertTrue(sorted(["Brown", "Green", "Blue"]) == sorted(key_list)) def test_median_dictionary_keys(self): """ Tests if the correct number of keys (experiment column names) is contained in the result dict and if the contained keys are identical to the column names. """ median_dict = self.analysis.get_bootstrapped_median() key_list, key_count = self.check_keys_in_dict(median_dict) self.assertEqual(3, key_count) self.assertTrue(sorted(["Brown", "Green", "Blue"]) == sorted(key_list)) def test_SEM(self): """ Tests if the correct number of keys (experiment column names) is contained in the result dict and if the contained keys are identical to the column names. """ sem_dict = self.analysis.get_bootstrapped_median() key_list, key_count = self.check_keys_in_dict(sem_dict) self.assertEqual(3, key_count) self.assertTrue(sorted(["Brown", "Green", "Blue"]) == sorted(key_list))
def __init__(self, filename, number_of_resamples=10000): """ Initializing the Bootstrapit class executes the resampling of the imported dataset. :param filename: The filename including filepath to the import data file. :param number_of_resamples: The number of resamples to perform. """ self.number_of_resamples = number_of_resamples # import dataset from file self.__fh = FileHandling() self.original_data_dict = self.__fh.import_spreadsheet(filename) # resample dataset self.__bootstrapper = Bootstrapper(self.original_data_dict, number_of_resamples) #init bootstrap analysis tools self.__analysis = BootstrapAnalysis(self.__bootstrapper) #init plotter self.__plotter = Plotting(self.__fh.export_order)
def __init__(self): self.MainWindow = QtWidgets.QMainWindow() self.ui = mw.Ui_MainWindow() self.ui.setupUi(self.MainWindow) self.MainWindow.closeEvent = self.closeEvent #wer weis ob das ok ist^^ self.ui.treeWidget_Produktion.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.ui.treeWidget_Produktion.customContextMenuRequested.connect(self.openMenu_treeItem) # self.ui.pushButton_Arbeitsschritt_hinzufgen.clicked.connect(self.pushButton_Arbeitsschritt_hinzufgen) # self.ui.pushButton_Schablone_hinzufgen.clicked.connect(self.pushButton_Schablone_hinzufgen) # self.ui.pushButton_Prozess_hinzufgen.clicked.connect(self.pushButton_Prozess_hinzufgen) self.ui.pushButton_Start.clicked.connect(self.pushButton_Start) self.ui.pushButton_Stop.clicked.connect(self.pushButton_Stop) self.ui.treeWidget_Produktion.itemDoubleClicked.connect(self.ondoubleclick) self.ui.treeWidget_Produktion.itemChanged.connect(self.treeWidget_Produktion_itemChanged) self.ui.treeWidget_Produktion.itemClicked.connect(self.treeWidget_Produktion_clicked) self.ui.actionopen.triggered.connect(self.actionOpen_clicked) self.ui.actionnew.triggered.connect(self.actionnew_clicked) self.ui.actionsave.triggered.connect(self.actionsave_clicked) self.ui.actionSettings.triggered.connect(self.actionSettings_clicked) self.ui.actionsave_as.triggered.connect(self.actionsave_as_clicked) self.treeWidget_Produktion_head: QtWidgets.QHeaderView = self.ui.treeWidget_Produktion.header() self.treeWidget_Produktion_head.setSectionsClickable(True) self.treeWidget_Produktion_head.sectionDoubleClicked.connect(self.treeWidget_Produktion_head_DoubleClicked) self.treeWidget_Produktion_head.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.treeWidget_Produktion_head.customContextMenuRequested.connect(self.openMenu_treeHead) # self.ui.treeWidget_Produktion.setAcceptDrops(True) # self.ui.treeWidget_Produktion.setDragEnabled(True) # self.ui.treeWidget_Produktion.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove) self.guiArbeitsschritt = gui_Arbeitsschritt.gui_Arbeitsschrit(self.MainWindow) self.guiSchablone = gui_Schablone.gui_Schablone(self.MainWindow) self.guiProzess = gui_Prozess.gui_Prozess(self.MainWindow) self.guiSetups = gui_Setups.gui_Setups(self.MainWindow) # item = my_QTreeWidgetItem.my_QTreeWidgetItem(self.ui.treeWidget_Produktion) self.filehandeling = FileHandling(".set") self.setups = model_Setups.Setups() # erstellen des Models self.running = False self.parents = {} # um die elemente im treeWidget löschen zu können weird eine Referenz auf das Elter benötigt self.update_TreeWidget() FileHandling.system_path = os.path.dirname(sys.argv[0]) # os.path.dirname(os.path.realpath(__file__)) self.settings = model_Settings.Settings() FileHandling.last_path = self.settings.setings["ablage"]["Pfad Programme"] self.plotter: model_Plotter.Plotter #self.status_text = "" self.update_gui()
class gui_MainWindow_PlotterWizard(): def __init__(self): self.MainWindow = QtWidgets.QMainWindow() self.ui = mw.Ui_MainWindow() self.ui.setupUi(self.MainWindow) self.MainWindow.closeEvent = self.closeEvent #wer weis ob das ok ist^^ self.ui.treeWidget_Produktion.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.ui.treeWidget_Produktion.customContextMenuRequested.connect(self.openMenu_treeItem) # self.ui.pushButton_Arbeitsschritt_hinzufgen.clicked.connect(self.pushButton_Arbeitsschritt_hinzufgen) # self.ui.pushButton_Schablone_hinzufgen.clicked.connect(self.pushButton_Schablone_hinzufgen) # self.ui.pushButton_Prozess_hinzufgen.clicked.connect(self.pushButton_Prozess_hinzufgen) self.ui.pushButton_Start.clicked.connect(self.pushButton_Start) self.ui.pushButton_Stop.clicked.connect(self.pushButton_Stop) self.ui.treeWidget_Produktion.itemDoubleClicked.connect(self.ondoubleclick) self.ui.treeWidget_Produktion.itemChanged.connect(self.treeWidget_Produktion_itemChanged) self.ui.treeWidget_Produktion.itemClicked.connect(self.treeWidget_Produktion_clicked) self.ui.actionopen.triggered.connect(self.actionOpen_clicked) self.ui.actionnew.triggered.connect(self.actionnew_clicked) self.ui.actionsave.triggered.connect(self.actionsave_clicked) self.ui.actionSettings.triggered.connect(self.actionSettings_clicked) self.ui.actionsave_as.triggered.connect(self.actionsave_as_clicked) self.treeWidget_Produktion_head: QtWidgets.QHeaderView = self.ui.treeWidget_Produktion.header() self.treeWidget_Produktion_head.setSectionsClickable(True) self.treeWidget_Produktion_head.sectionDoubleClicked.connect(self.treeWidget_Produktion_head_DoubleClicked) self.treeWidget_Produktion_head.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.treeWidget_Produktion_head.customContextMenuRequested.connect(self.openMenu_treeHead) # self.ui.treeWidget_Produktion.setAcceptDrops(True) # self.ui.treeWidget_Produktion.setDragEnabled(True) # self.ui.treeWidget_Produktion.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove) self.guiArbeitsschritt = gui_Arbeitsschritt.gui_Arbeitsschrit(self.MainWindow) self.guiSchablone = gui_Schablone.gui_Schablone(self.MainWindow) self.guiProzess = gui_Prozess.gui_Prozess(self.MainWindow) self.guiSetups = gui_Setups.gui_Setups(self.MainWindow) # item = my_QTreeWidgetItem.my_QTreeWidgetItem(self.ui.treeWidget_Produktion) self.filehandeling = FileHandling(".set") self.setups = model_Setups.Setups() # erstellen des Models self.running = False self.parents = {} # um die elemente im treeWidget löschen zu können weird eine Referenz auf das Elter benötigt self.update_TreeWidget() FileHandling.system_path = os.path.dirname(sys.argv[0]) # os.path.dirname(os.path.realpath(__file__)) self.settings = model_Settings.Settings() FileHandling.last_path = self.settings.setings["ablage"]["Pfad Programme"] self.plotter: model_Plotter.Plotter #self.status_text = "" self.update_gui() def __del__(self): print("close") def conact_Plotter(self): self.plotter = model_Plotter.Plotter(self.settings) def update_gui(self): pass def update_status_Text(self): self.ui.textEdit_Statu_Meldung.setText(status_text.text) self.ui.textEdit_Statu_Meldung.moveCursor(QtGui.QTextCursor.End) def add_part_count(self): self.ui.spinBox_part_count.setValue(self.ui.spinBox_part_count.value()+1) def update_TreeWidget(self): self.ui.treeWidget_Produktion.clear() self.ui.treeWidget_Produktion.headerItem().setText(0, self.setups.name) self.parents = {} for schablone in self.setups.schablonen: item = my_QTreeWidgetItem.my_QTreeWidgetItem(self.ui.treeWidget_Produktion) item.setText(0, schablone.name) item.setFlags(item.flags() | QtCore.Qt.ItemIsTristate | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(0, schablone.enabled) item.modul = schablone self.ui.treeWidget_Produktion.addTopLevelItem(item) self.parents[id(schablone)] = self.setups.schablonen for prozzess in schablone.prozesse: item2 = my_QTreeWidgetItem.my_QTreeWidgetItem(item) item2.setText(0, prozzess.name) item2.setFlags(item2.flags() | QtCore.Qt.ItemIsTristate | QtCore.Qt.ItemIsUserCheckable) item2.setCheckState(0, prozzess.enabled) item2.modul = prozzess item.addChild(item2) self.parents[id(prozzess)] = schablone.prozesse for arbeitsscritt in prozzess.arbeitsschritte: item3 = my_QTreeWidgetItem.my_QTreeWidgetItem(item) item3.setText(0, arbeitsscritt.name) item3.setFlags(item3.flags() | QtCore.Qt.ItemIsUserCheckable) item3.setCheckState(0, arbeitsscritt.enabled) item3.modul = arbeitsscritt item2.addChild(item3) self.parents[id(arbeitsscritt)] = prozzess.arbeitsschritte self.ui.treeWidget_Produktion.expandAll() def show(self): self.MainWindow.show() def pushButton_Start(self): self.running = True self.plotter.prozess_init(self.setups.encode()) self.plotter.prozess_start() self.update_gui() def pushButton_Stop(self): self.running = False self.plotter.prozess_stop() self.update_gui() pass def ondoubleclick(self, previous): self.edit_modul(self.ui.treeWidget_Produktion.currentItem().modul) def treeWidget_Produktion_clicked(self, event): self.ui.treeWidget_Produktion.clearSelection() def treeWidget_Produktion_itemChanged(self, event: my_QTreeWidgetItem.my_QTreeWidgetItem): event.modul.enabled = event.checkState(0) def treeWidget_Produktion_head_DoubleClicked(self, evebt): self.edit_modul(None) def edit_modul(self, modul): if type(modul) is model_Schablone.Schablone: self.guiSchablone.show(modul) if type(modul) is model_Prozess.Prozess: self.guiProzess.show(modul) if type(modul) is model_Arbeitsschritt.Arbeitsschritt: self.guiArbeitsschritt.show(modul) if modul is None: self.guiSetups.show(self.setups) self.update_TreeWidget() def add_modul(self, modul): if type(modul) is model_Schablone.Schablone: md: model_Schablone.Schablone = modul md.prozesse.append(model_Prozess.Prozess()) if type(modul) is model_Prozess.Prozess: md: model_Prozess.Prozess = modul md.arbeitsschritte.append(model_Arbeitsschritt.Arbeitsschritt()) if modul is None: self.setups.schablonen.append(model_Schablone.Schablone()) self.update_TreeWidget() def delete_modul(self, modul): if type(modul) is model_Schablone.Schablone: md: model_Schablone.Schablone = modul self.parents[id(md)].remove(md) if type(modul) is model_Prozess.Prozess: md: model_Prozess.Prozess = modul self.parents[id(md)].remove(md) if type(modul) is model_Arbeitsschritt.Arbeitsschritt: md: model_Arbeitsschritt.Arbeitsschritt = modul self.parents[id(md)].remove(md) self.update_TreeWidget() def move_up(self, modul): if type(modul) is model_Schablone.Schablone: md: model_Schablone.Schablone = modul liste = self.parents[id(md)] oldindex = liste.index(md) if oldindex > 0: liste.insert(oldindex-1, liste.pop(oldindex)) if type(modul) is model_Prozess.Prozess: md: model_Prozess.Prozess = modul liste = self.parents[id(md)] oldindex = liste.index(md) if oldindex > 0: liste.insert(oldindex-1, liste.pop(oldindex)) if type(modul) is model_Arbeitsschritt.Arbeitsschritt: md: model_Arbeitsschritt.Arbeitsschritt = modul liste = self.parents[id(md)] oldindex = liste.index(md) if oldindex > 0: liste.insert(oldindex-1, liste.pop(oldindex)) self.update_TreeWidget() def move_down(self, modul): if type(modul) is model_Schablone.Schablone: md: model_Schablone.Schablone = modul liste = self.parents[id(md)] oldindex = liste.index(md) if oldindex < len(liste): liste.insert(oldindex+1, liste.pop(oldindex)) if type(modul) is model_Prozess.Prozess: md: model_Prozess.Prozess = modul liste = self.parents[id(md)] oldindex = liste.index(md) if oldindex < len(liste): liste.insert(oldindex+1, liste.pop(oldindex)) if type(modul) is model_Arbeitsschritt.Arbeitsschritt: md: model_Arbeitsschritt.Arbeitsschritt = modul liste = self.parents[id(md)] oldindex = liste.index(md) if oldindex < len(liste): liste.insert(oldindex+1, liste.pop(oldindex)) self.update_TreeWidget() def openMenu_treeItem(self, event: QtCore.QPoint): menu = QtWidgets.QMenu() edit = menu.addAction("edit") add = menu.addAction("add") delete = menu.addAction("delete") move_up = menu.addAction("move up") move_down = menu.addAction("move down") action = menu.exec_(self.ui.treeWidget_Produktion.mapToGlobal(event)) if action == edit: if self.ui.treeWidget_Produktion.currentItem() is None: pass else: self.edit_modul(self.ui.treeWidget_Produktion.currentItem().modul) if action == add: if self.ui.treeWidget_Produktion.currentItem() is None: self.add_modul(None) else: self.add_modul(self.ui.treeWidget_Produktion.currentItem().modul) if action == delete: if self.ui.treeWidget_Produktion.currentItem() is None: pass else: self.delete_modul(self.ui.treeWidget_Produktion.currentItem().modul) if action == move_up: if self.ui.treeWidget_Produktion.currentItem() is None: pass else: self.move_up(self.ui.treeWidget_Produktion.currentItem().modul) if action == move_down: if self.ui.treeWidget_Produktion.currentItem() is None: pass else: self.move_down(self.ui.treeWidget_Produktion.currentItem().modul) def openMenu_treeHead(self, event: QtCore.QPoint): menu = QtWidgets.QMenu() add = menu.addAction("add") edit = menu.addAction("edit") action = menu.exec_(self.ui.treeWidget_Produktion.mapToGlobal(event)) if action == add: self.add_modul(None) if action == edit: self.edit_modul(None) def actionOpen_clicked(self): data = self.filehandeling.open_projekt(self.settings.setings["ablage"]["Pfad Programme"]) if data is not None: self.setups.__init__(**data) self.update_TreeWidget() self.update_gui() def actionnew_clicked(self): FileHandling.path_of_open_projekt = None self.setups = model_Setups.Setups() self.update_TreeWidget() def actionsave_clicked(self): self.filehandeling.safe_projekt(self.setups, self.setups.name) def actionsave_as_clicked(self): self.filehandeling.safe_projekt_as(self.setups, self.setups.name) def actionSettings_clicked(self): gui = gui_Sttings.gui_Settings(self.MainWindow, self.settings) gui.show() self.pushButton_Stop() self.plotter.reinit_rs232(self.settings) self.update_gui() def closeEvent(self, event): print("closing") self.pushButton_Stop() event.accept()
class Bootstrapit: """ The Bootstrapit class builds the API for the Bootstrapit application. The Methods inside this class can directly be used to interact with the application. """ def __init__(self, filename, number_of_resamples=10000): """ Initializing the Bootstrapit class executes the resampling of the imported dataset. :param filename: The filename including filepath to the import data file. :param number_of_resamples: The number of resamples to perform. """ self.number_of_resamples = number_of_resamples # import dataset from file self.__fh = FileHandling() self.original_data_dict = self.__fh.import_spreadsheet(filename) # resample dataset self.__bootstrapper = Bootstrapper(self.original_data_dict, number_of_resamples) #init bootstrap analysis tools self.__analysis = BootstrapAnalysis(self.__bootstrapper) #init plotter self.__plotter = Plotting(self.__fh.export_order) # TODO: Export bootstrapped data array to json or excel def export(self, *export_datasets_dicts, filename="bootstrapit_results.xlsx"): """ The export method does merge all data analysis result dictionaries and exports them using the FileHandler class. :param export_datasets_dicts: All result dictionaries from the bootstrapping analysis. :param filename: the export filename. """ merged_dict = self.__merge_dicts(*export_datasets_dicts) filetype_check = filename.split('.') filetype = filetype_check[-1] filename = filetype_check[0] if filetype == "xlsx": self.__fh.file_type = FileType.XLSX elif filetype == "xls": self.__fh.file_type = FileType.XLS elif filetype == "csv": self.__fh.file_type = FileType.CSV else: print("Error: Unsupported file type.") self.__fh.file_name = filename self.__fh.export(merged_dict) def __merge_dicts(self, *dict_args): """ Helper method to merge multiple result dictionaries. :param dict_args: List of dictionaries :return: The merged dictionary containing all results of the analysis. """ result = {} for dictionary in dict_args: result.update(dictionary) return result def mean(self): return self.__analysis.get_bootstrapped_mean() def median(self): return self.__analysis.get_bootstrapped_median() def SEM(self): return self.__analysis.get_SEM() def barchart(self, figure, data_dict, errorbar = {}): return self.__plotter.plot_barchart(figure, data_dict, errorbar) def set_axis_label(self, axes, title, xlabel, ylabel): self.__plotter.set_axis_labels(axes, title, xlabel, ylabel)