def update_global_tolerances(self): controller = self.controller case = self.case pvals = self.pvals if pvals is None: self.tolerances_table.children = [] return if case.is_valid(p_bounds=pvals) is False: self.tolerances_table.children = [] return table = HTML() html_str = '<div><table>\n<caption>Global tolerances determined for Case ' + case.case_number + ' (' + case.signature + ') showing fold-difference to a large qualitative change{0}. </caption>\n'.format(' in log-coordinates' if self.log_coordinates is True else '') html_str += '<tr ><th align=center rowspan=2 style="padding:0 15px 0 15px;"> Parameters </th><th colspan=2> Tolerance </th></tr>' html_str += '<tr><td style="padding:0 15px 0 15px;"><b> Lower bound</b></td><td style="padding:0 15px 0 15px;"><b> Upper bound</b></td></tr>' tolerances = case.measure_tolerance(pvals, log_out=self.log_coordinates) for xi in sorted(pvals.keys()): lower_th = 1e-15 if self.log_coordinates is False else -15 upper_th = 1e15 if self.log_coordinates is False else 15 lower, upper = tolerances[xi] html_str += '<tr><td style="padding:0 15px 0 15px;"><b>{0}</b></td><td style="padding:0 15px 0 15px;">{1}</td><td style="padding:0 15px 0 15px;">{2}</td></tr>'.format( xi, lower if lower > lower_th else '-∞', upper if upper < upper_th else '∞') html_str += '</table><caption>' html_str += 'Note: Global tolerance calculated based on the following values for the parameters: ' html_str += '; '.join([i + ' = ' + str(pvals[i]) for i in sorted(pvals.keys())]) + '.' html_str += '</caption></div>' table.value = html_str save_button = Button(description='Save Global Tolerance Table') save_button.table_data = html_str save_button.on_click(self.save_table) self.tolerances_table.children = [HTML(value='<br>'), save_button, table] return
def update_parameter_table(self): controller = self.controller case = self.case pvals = self.pvals if pvals is None: self.parameter_table.children = [] return if case.is_valid(p_bounds=pvals) is False: self.parameter_table.children = [] return make_nominal = Button(description='Make Nominal Parameter Set') make_nominal.on_click(self.save_parameters) table = HTML() html_str = '<div><table>\n<caption>Value for the parameters automatically determined for Case ' + case.case_number + ' (' + case.signature + '). </caption>\n' html_str += '<tr ><th align=center style="padding:0 15px 0 15px;"> Parameters </th><th> Value </th>' for xi in sorted(pvals.keys()): html_str += '<tr><td><b>{0}</b></td><td>{1}</td></tr>'.format( xi, pvals[xi]) html_str += '</table></div>' table.value = html_str save_button = Button(description='Save Parameter Table') save_button.table_data = html_str save_button.on_click(self.save_table) self.parameter_table.children = [HTML(value='<br>'), save_button, table, make_nominal ] return
def update_bounding_box(self): controller = self.controller case = self.case pvals = self.pvals if case.is_valid(p_bounds=pvals) is False: self.bounding_box_table.children = [] return if case.is_cyclical is True: self.bounding_box_table.children = [] return table = HTML() html_str = '<div><table>\n<caption>Bounding box determined for Case ' + case.case_number + ' (' + case.signature + '){0}. </caption>\n'.format(' in log-coordinates' if self.log_coordinates is True else '') html_str += '<tr ><th align=center rowspan=2 style="padding:0 15px 0 15px;"> Parameters </th><th colspan=2> Tolerance </th></tr>' html_str += '<tr><td style="padding:0 15px 0 15px;"><b> Lower bound</b></td><td style="padding:0 15px 0 15px;"><b> Upper bound</b></td></tr>' tolerances = case.bounding_box(log_out=self.log_coordinates) for xi in sorted(tolerances.keys()): lower_th = 1e-15 if self.log_coordinates is False else -15 upper_th = 1e15 if self.log_coordinates is False else 15 lower, upper = tolerances[xi] html_str += '<tr><td style="padding:0 15px 0 15px;"><b>{0}</b></td><td style="padding:0 15px 0 15px;">{1}</td><td style="padding:0 15px 0 15px;">{2}</td></tr>'.format( xi, lower if lower > lower_th else '-∞', upper if upper < upper_th else '∞') html_str += '</table></div>' table.value = html_str save_button = Button(description='Save Bounding Box Table') save_button.table_data = html_str save_button.on_click(self.save_table) self.bounding_box_table.children = [HTML(value='<br>'), save_button, table] return
def update_log_gains(self): controller = self.controller case = self.case if case.ssystem.solution is None: self.log_gains.children = [] return table = HTML() html_str = '<div><table>\n<caption>Logarithmic gains and parameter sensitivities for Case ' + case.case_number + ' (' + case.signature + '). </caption>\n' html_str += '<tr ><th rowspan="2" align=center style="padding:0 15px 0 15px;"> Dependent<br> Variables </th>' html_str += '<th colspan="' + str(len(case.independent_variables)) + '" align=center style="padding:0 15px 0 15px;"> Independent Variables and Parameters</th></tr><tr align=center>' for xi in case.independent_variables: html_str += '<td><b>{0}</b></td>'.format(xi) html_str += '</tr>\n' for xd in case.dependent_variables: html_str += '<tr><td align=center style="padding:0 15px 0 15px;"><b>{0}</b></td>'.format(xd) for xi in case.independent_variables: html_str += '<td align=center style="padding:0 15px 0 15px;">{0}</td>'.format(str(case.ssystem.log_gain(xd, xi))) html_str += '</tr>\n' html_str += '</table></div><br>' save_button = Button(description='Save Log-Gain Table') save_button.table_data = html_str save_button.on_click(self.save_table) table.value = html_str self.log_gains.children = [HTML(value='<br>'), save_button, table] return
def make_options_menu(self, b): wi = b.wi b.visible = False b.name.visible = False b.load.visible = False actions = [('Enumerate Phenotypes', self.enumerate_phenotypes_menu), ('Analyze Case', self.case_report_menu), ('Intersect Phenotypes', self.case_intersect_menu), ('Co-localize Phenotypes', self.co_localize_menu), ('Create Plot', self.create_plot_menu)] actions_h = HTML(value='<b>Actions</b>') options_h = HTML(value='<b>Options</b>') options = [('Edit Symbols', self.create_edit_symbols), ('Edit Parameters', self.create_edit_parameters), ('Save Data', self.save_widget_data)] actions_w = Tab() options_w = [] for name, method in options: button = Button(description=name) button.on_click(method) ## button.version = b.version if method is None: button.disabled = True options_w.append(button) edit = Button(description='Modify System') edit.on_click(self.modify_equations_widget) warning = HTML() warning.value = '<font color="red"><b>Warning! Modifying system erases saved figures and tables.</b></font>' wi.children = [actions_h, actions_w] + [options_h] + options_w + [edit, warning] for title, method in actions: title, widget = method(self) children = [i for i in actions_w.children] + [widget] actions_w.children = children actions_w.set_title(len(children)-1, title) self.widget.selected_index = 1
def update_info(self): controller = self.controller html = HTML() html_string = '<b>Name:</b> ' + controller.name + '<br>' html_string += '<b>Case Number:</b> ' + self.case.case_number + '<br>' html_string += '<b>Case Signature:</b> (' + self.case.signature + ')<br>' html_string += '<b>Valid:</b> ' + str(self.case.is_valid()) + '<br>' html_string += '<b>Is Cyclical:</b> ' + str(self.case.is_cyclical) + '<br><hr>' check_box = Checkbox(description='Logarithmic coordinates', value=self.log_coordinates) check_box.on_trait_change(self.change_logarithmic, 'value') html.value = html_string self.info.children = [html, check_box]