def _on_export(self): dialog = DefaultFileDialog(parent = None, action = 'save as', default_suffix = "csv", wildcard = (FileDialog.create_wildcard("CSV", "*.csv") + ';' + #@UndefinedVariable FileDialog.create_wildcard("All files", "*"))) #@UndefinedVariable if dialog.open() != OK: return data = pd.DataFrame(index = self.result.index) data[self.result.name] = self.result self._export_data(data, self.result.name, dialog.path)
def on_problem(self): log = str(self._get_package_versions()) + "\n" + self.application.application_log.getvalue() msg = "The best way to report a problem is send an application log to " \ "the developers. If you click 'Yes' below, you will be given then " \ "opportunity to save the log to a file and then file a " \ "new issue on GitHub at " \ "https://github.com/cytoflow/cytoflow/issues/new" dialog = ConfirmationDialog(message = msg, informative = "Would you like to report an issue to the developers?") if dialog.open() == YES: dialog = DefaultFileDialog(parent = self.window.control, action = 'save as', default_suffix = "log", wildcard = (FileDialog.create_wildcard("Log files", "*.log") + ';' + #@UndefinedVariable FileDialog.create_wildcard("All files", "*"))) #@UndefinedVariable if dialog.open() == OK: with open(dialog.path, 'w') as f: f.write(log) webbrowser.open_new_tab("https://github.com/cytoflow/cytoflow/issues/new") return
def on_save_as(self): dialog = DefaultFileDialog( parent=self.window.control, action='save as', default_suffix="flow", wildcard=( FileDialog.create_wildcard("Cytoflow workflow", "*.flow") + ';' + #@UndefinedVariable FileDialog.create_wildcard("All files", "*"))) #@UndefinedVariable if dialog.open() == OK: self.save_file(dialog.path) self.filename = dialog.path self.window.title = "Cytoflow - " + self.filename pass
def on_notebook(self): """ Shows a dialog to export the workflow to an Jupyter notebook """ dialog = DefaultFileDialog( parent=self.window.control, action='save as', default_suffix="ipynb", wildcard=( FileDialog.create_wildcard("Jupyter notebook", "*.ipynb") + ';' + #@UndefinedVariable FileDialog.create_wildcard("All files", "*"))) # @UndefinedVariable if dialog.open() == OK: save_notebook(self.model.workflow, dialog.path)
def on_problem(self): log = str(self._get_package_versions()) + "\n" + self.application.application_log.getvalue() msg = "The best way to report a problem is send an application log to " \ "the developers. You can do so by either sending us an email " \ "with the log in it, or saving the log to a file and filing a " \ "new issue on GitHub at " \ "https://github.com/bpteague/cytoflow/issues/new" dialog = ConfirmationDialog(message = msg, informative = "Which would you like to do?", yes_label = "Send an email...", no_label = "Save to a file...") if dialog.open() == NO: dialog = DefaultFileDialog(parent = self.window.control, action = 'save as', default_suffix = "log", wildcard = (FileDialog.create_wildcard("Log files", "*.log") + ';' + #@UndefinedVariable FileDialog.create_wildcard("All files", "*"))) #@UndefinedVariable if dialog.open() == OK: with open(dialog.path, 'w') as f: f.write(log) webbrowser.open_new_tab("https://github.com/bpteague/cytoflow/issues/new") return information(None, "I'll now try to open your email client and create a " "new message to the developer. Debugging logs are " "attached. Please fill out the template bug report and " "send -- thank you for reporting a bug!") log = self.application.application_log.getvalue() versions = ["{0} {1}".format(key, value) for key, value in self._get_package_versions().items()] body = """ Thank you for your bug report! Please fill out the following template. PLATFORM (Mac, PC, Linux, other): OPERATING SYSTEM (eg OSX 10.7, Windows 8.1): SEVERITY (Critical? Major? Minor? Enhancement?): DESCRIPTION: - What were you trying to do? - What happened? - What did you expect to happen? PACKAGE VERSIONS: {0} DEBUG LOG: {1} """.format(versions, log) mailto("*****@*****.**", subject = "Cytoflow bug report", body = body)
def _on_export(self): dialog = DefaultFileDialog( parent=None, action='save as', default_suffix="csv", wildcard=( FileDialog.create_wildcard("CSV", "*.csv") + ';' + #@UndefinedVariable FileDialog.create_wildcard("All files", "*"))) #@UndefinedVariable if dialog.open() != OK: return data = pd.DataFrame(index=self.result.index) data[self.result.name] = self.result if self.subset: data = data.query(self.subset) names = list(data.index.names) for name in names: unique_values = data.index.get_level_values(name).unique() if len(unique_values) == 1: data.index = data.index.droplevel(name) facets = [ x for x in [ self.row_facet, self.subrow_facet, self.column_facet, self.subcolumn_facet ] if x ] if set(facets) != set(data.index.names): raise util.CytoflowViewError( "Must use all the statistic indices as variables or facets: {}" .format(data.index.names)) row_groups = data.index.get_level_values(self.row_facet).unique() \ if self.row_facet else [None] subrow_groups = data.index.get_level_values(self.subrow_facet).unique() \ if self.subrow_facet else [None] col_groups = data.index.get_level_values(self.column_facet).unique() \ if self.column_facet else [None] subcol_groups = data.index.get_level_values(self.subcolumn_facet).unique() \ if self.subcolumn_facet else [None] row_offset = (self.column_facet != "") + (self.subcolumn_facet != "") col_offset = (self.row_facet != "") + (self.subrow_facet != "") num_rows = len(row_groups) * len(subrow_groups) + row_offset num_cols = len(col_groups) * len(subcol_groups) + col_offset t = np.empty((num_rows, num_cols), dtype=np.object_) # make the main table for (ri, r) in enumerate(row_groups): for (rri, rr) in enumerate(subrow_groups): for (ci, c) in enumerate(col_groups): for (cci, cc) in enumerate(subcol_groups): row_idx = ri * len(subrow_groups) + rri + row_offset col_idx = ci * len(subcol_groups) + cci + col_offset # agg_idx = [x for x in (r, rr, c, cc) if x is not None] # agg_idx = tuple(agg_idx) # if len(agg_idx) == 1: # agg_idx = agg_idx[0] # t[row_idx, col_idx] = self.result.get(agg_idx) # this is not pythonic, but i'm tired agg_idx = [] for data_idx in data.index.names: if data_idx == self.row_facet: agg_idx.append(r) elif data_idx == self.subrow_facet: agg_idx.append(rr) elif data_idx == self.column_facet: agg_idx.append(c) elif data_idx == self.subcolumn_facet: agg_idx.append(cc) agg_idx = tuple(agg_idx) if len(agg_idx) == 1: agg_idx = agg_idx[0] try: text = "{:g}".format( data.loc[agg_idx][self.result.name]) except ValueError: text = data.loc[agg_idx][self.result.name] t[row_idx, col_idx] = self.result.get(agg_idx) # row headers if self.row_facet: for (ri, r) in enumerate(row_groups): row_idx = ri * len(subrow_groups) + row_offset text = "{0} = {1}".format(self.row_facet, r) t[row_idx, 0] = text # subrow headers if self.subrow_facet: for (ri, r) in enumerate(row_groups): for (rri, rr) in enumerate(subrow_groups): row_idx = ri * len(subrow_groups) + rri + row_offset text = "{0} = {1}".format(self.subrow_facet, rr) t[row_idx, 1] = text # column headers if self.column_facet: for (ci, c) in enumerate(col_groups): col_idx = ci * len(subcol_groups) + col_offset text = "{0} = {1}".format(self.column_facet, c) t[0, col_idx] = text # column headers if self.subcolumn_facet: for (ci, c) in enumerate(col_groups): for (cci, cc) in enumerate(subcol_groups): col_idx = ci * len(subcol_groups) + cci + col_offset text = "{0} = {1}".format(self.subcolumn_facet, c) t[1, col_idx] = text np.savetxt(dialog.path, t, delimiter=",", fmt="%s")