def __makeEquations(self, variable_class, selection, autoexclusive=True): self.current_equation_IDs = {} index = 1 equations = [M_None] self.current_equation_IDs[0] = None indices = self.ontology_container.indices equation_ID_list = [] for var_ID in self.variables: var = self.variables[var_ID] if var["network"] == self.current_node_network: if var["type"] == variable_class: lhs = var["label"] for eq_ID in var["equations"]: equ = var["equations"][eq_ID] if equ["network"] == self.current_node_network: expression = equ["rhs"] rhs = renderExpressionFromGlobalIDToInternal( expression, self.variables, indices) entry = "%s %s = %s" % (eq_ID, lhs, rhs) equations.append(entry) self.current_equation_IDs[index] = eq_ID index += 1
def __makeEquationList(self): equation_list = {} for eq_ID in self.equation_dictionary: var_ID, equation = self.equation_dictionary[eq_ID] # print(var_ID, eq_ID, equation) if self.current_node_network == equation["network"]: var_class = self.variables[var_ID]["type"] if var_class == "state": equation_list[eq_ID] = (var_ID, var_class, equation["rhs"]) for eq_ID in equation_list: print(eq_ID, " -- ", equation_list[eq_ID]) if len(equation_list) > 0: rendered_expressions = {} radio_item_list = [] self.inverse_dictionary = {} # hash: label, value: (var_ID, eq_ID) for eq_ID in equation_list: rendered_expressions[ eq_ID] = renderExpressionFromGlobalIDToInternal( equation_list[eq_ID][2], self.variables, self.indices) var_ID = equation_list[eq_ID][0] rendered_variable = self.variables[ equation_list[eq_ID][0]]["aliases"]["internal_code"] print(rendered_variable, rendered_expressions[eq_ID]) s = "%s := %s" % (rendered_variable, rendered_expressions[eq_ID]) radio_item_list.append(s) self.inverse_dictionary[s] = (var_ID, eq_ID) self.radio = UI_RadioSelector(radio_item_list, [], allowed=1) self.radio.setWindowTitle("select one") self.radio.rejected.connect(self.__gotState) self.radio.exec_()
def __makeEquationList(self): self.inverse_dictionary = {} # hash: label, value: (var_ID, eq_ID) equation_list = {} rendered_equation_list = {} self.inverse_dictionary = {} # for component in self.rules: # for nw in self.ontology_container.networks: #rules[component]: equation_variable_dictionary = self.ontology_container.equation_variable_dictionary for eq_ID in equation_variable_dictionary: var_ID, equation = equation_variable_dictionary[eq_ID] var_type = self.ontology_container.variables[var_ID]["type"] nw = self.ontology_container.variables[var_ID]["network"] if nw not in equation_list: equation_list[nw] = {} if nw not in rendered_equation_list: rendered_equation_list[nw] = {} if var_type not in equation_list[nw]: equation_list[nw][var_type] = {} rendered_equation_list[nw][var_type] = {} equation_list[nw][var_type][eq_ID] = (var_ID, var_type, equation["rhs"], equation["network"]) # for var_type in equation_list[nw]: # for eq_ID in equation_list[nw][var_type]: # print(eq_ID, " -- ", equation_list[nw][var_type][eq_ID]) rendered_expressions = renderExpressionFromGlobalIDToInternal( equation["rhs"], self.ontology_container.variables, self.ontology_container.indices) rendered_variable = self.ontology_container.variables[ equation_list[nw][var_type][eq_ID] [0]]["aliases"]["internal_code"] # print("debugging -- rendered equation info", rendered_variable, rendered_expressions[var_type][eq_ID]) s = "%s := %s" % (rendered_variable, rendered_expressions) # radio_item_list.append(s) # print("debugging variable class") if var_ID not in rendered_equation_list[nw][var_type]: rendered_equation_list[nw][var_type][var_ID] = [] rendered_equation_list[nw][var_type][var_ID].append(s) self.inverse_dictionary[s] = (var_ID, eq_ID) self.rendered_equation = rendered_equation_list
def __makeEquations(self, variable_class, selection, autoexclusive=True): self.current_equation_IDs = {} index = 1 equations = [M_None] self.current_equation_IDs[0] = None indices = self.ontology_container.indices equation_ID_list = [] for var_ID in self.variables: var = self.variables[var_ID] if var["network"] == self.current_node_network: if var["type"] == variable_class: lhs = var["label"] for eq_ID in var["equations"]: equ = var["equations"][eq_ID] if equ["network"] == self.current_node_network: expression = equ["rhs"] rhs = renderExpressionFromGlobalIDToInternal( expression, self.variables, indices) entry = "%s %s = %s" % (eq_ID, lhs, rhs) equations.append(entry) self.current_equation_IDs[index] = eq_ID index += 1 # eqs = self.variables[var_ID]["equations"] #["equation_list"] # equation_ID_list.extend(eqs) # for ID in equation_ID_list: # lhs = self.equations[ID]["lhs"] # rhs = self.equations[ID]["rhs"] # entry = "%s %s = %s" % (ID, lhs, rhs) # equations.append(entry) # self.current_equation_IDs[index] = ID # index += 1 self.radio_selectors["equations"] = self.__makeAndAddRadioSelector( "equations", equations, self.radioReceiverEquations, selection, self.ui.horizontalLayoutEquations, autoexclusive=autoexclusive) self.radio_selectors["equations"].show() self.ui.groupBoxEquations.show()
def __makeEquationAndIndexLists(self): """ equations : list of equation IDs equation_information : dictionary of tuples eq_ID, var_ID, var_type, nw_eq, equation_label """ # TODO: drop pixel version and use info being generated in the ontology_container equations = [] equation_information = {} equation_inverse_index = {} equation_variable_dictionary = self.ontology_container.equation_variable_dictionary count = -1 for eq_ID in equation_variable_dictionary: count += 1 var_ID, equation = equation_variable_dictionary[eq_ID] var_type = self.ontology_container.variables[var_ID]["type"] nw_eq = self.ontology_container.variables[var_ID]["network"] if pixel_or_text == "text": rendered_expressions = renderExpressionFromGlobalIDToInternal( equation["rhs"], self.ontology_container.variables, self.ontology_container.indices) rendered_variable = self.ontology_container.variables[var_ID][ "aliases"]["internal_code"] equation_label = "%s := %s" % (rendered_variable, rendered_expressions) elif pixel_or_text == "pixelled": equation_label = self.__make_icon(eq_ID) # equations[eq_ID] = (var_ID, var_type, nw_eq, rendered_equation, pixelled_equation) equations.append(equation_label) equation_inverse_index[eq_ID] = count equation_information[count] = (eq_ID, var_ID, var_type, nw_eq, equation_label) return equations, equation_information, equation_inverse_index