def _trousseau2allfields(self, T, sort_it=True): """ Generates latex code for the verbose of a list of ccsds keys Args: * T (trousseau): the trousseau to generate code on * sort_it (bool): whether to re-order the keys using their start values """ if T is None or getattr(T, 'size', 0) == 0: return [] unit = "octet" if T.octets else "bit" if sort_it: Tkeys = sorted(T.keys, key=lambda x: x.start) else: Tkeys = T.keys res = [] start_bit = 0 for cle in Tkeys: clesection = Subsubsection(cle.name) items = [] if not cle.relative_only: start_bit = cle.start # if no padding, allows flexible len of the ccsdskey the_len = cle.len if cle.pad else "[0..{:d}]".format(cle.len) if cle.isdic: the_verbose = "N/A" if cle.dic_force is not None: the_type = repr(cle.dic[cle.dic_force]) else: the_type = repr(cle.dic.values()) else: the_type = re.search(r'type *= *([\S ]+)', getattr(cle._fctunpack, 'func_doc', '')) the_verbose = re.search( r'verbose *= *([\S ]+)', getattr(cle._fctunpack, 'func_doc', '')) if the_type is None: the_type = '-' else: the_type = the_type.group(1) if the_verbose is None: the_verbose = "N/A" else: the_verbose = the_verbose.group(1) items += [r"{}".format(cle.verbose), r"Start {}: {}, length ({}s): {}, value: {}"\ .format(unit, start_bit, unit, the_len, the_type), r"Conversion: {}".format(the_verbose)] if cle.name != cle.disp: items += ["Shortened as '{}'".format(cle.disp)] for item in items: clesection.append(item) clesection.append(NewLine()) res.append(clesection) start_bit += cle.len return res
def __detailsFZN(self, doc, options, optPerSol, fnames, maxtime, bestever): coords = {} objs = {} for o in options: coords[o] = [] objs[o] = [] objs['syb'] = [] pol = 'SAT' presec = "" prevsubsec = "" section = None subsection = None # Third problem per problem k = 0 for fname in fnames: parts = fname.split("+") solutions = optPerSol[fname] if parts[0] != presec: presec = parts[0] if k > 0: self.__addTimePlots(doc, options, coords) for o in options: coords[o].clear() k = 0 if len(objs) > 0: self.__addObjPlots(doc, options, objs, pol) for o in objs.keys(): objs[o].clear() section = Section('%s' % (presec)) # .replace("_", "\_"))) doc.append(section) print("create section: " + presec) if parts[1] != prevsubsec: prevsubsec = parts[1] subsection = Subsection('%s' % (prevsubsec)) # .replace("_", "\_"))) section.append(subsection) print("create subsection: " + prevsubsec) if len(parts) > 2: subsubsection = Subsubsection( '%s' % (parts[2])) # .replace("_", "\_"))) subsection.append(subsubsection) print("create subsubsection: " + parts[2]) else: subsubsection = Subsubsection( '%s' % (parts[1])) # .replace("_", "\_"))) subsection.append(subsubsection) print("create subsubsection: " + parts[1]) pol = solutions[0][3] if solutions[0][3] == 'SAT': solutions.sort(key=lambda x: (x[3], x[1])) table = Tabular('l|r|l|r|r|r') subsubsection.append(table) table.add_hline() table.add_row(("Config.", 'Status', "#Sol", 'Time(sec)', 'Build(sec)', 'Nodes')) table.add_hline() for i in range(0, len(solutions)): table.add_row( (solutions[i][6], solutions[i][5], solutions[i][0], solutions[i][1], solutions[i][7], solutions[i][2])) coords[solutions[i][6]].append((k, solutions[i][1])) table.add_hline() table.add_hline() # add syb if fname in bestever: table.add_row("syb", bestever[fname][0], "--", "--", "--", "--") table.add_hline() else: # sort for MIN type = 'MIN' solutions.sort(key=lambda x: (x[3], x[4], x[1])) best = solutions[0][4] # check first row and last row if solutions[0][3] == 'MAX' or solutions[len(solutions) - 1][3] == 'MAX': solutions.sort(key=lambda x: (x[3], -x[4], x[1])) best = solutions[0][4] type = 'MAX' table = Tabular('l|r|l|r|r|r|r') subsubsection.append(table) table.add_hline() table.add_row(("Config.", type, 'Status', "#Sol", 'Time(sec)', 'Build(sec)', 'Nodes')) table.add_hline() for i in range(0, len(solutions)): table.add_row( (solutions[i][6], solutions[i][4], solutions[i][5], solutions[i][0], solutions[i][1], solutions[i][7], solutions[i][2])) if solutions[i][4] == best: coords[solutions[i][6]].append((k, solutions[i][1])) else: coords[solutions[i][6]].append((k, maxtime)) if int(solutions[i][0]) > 0: objs[solutions[i][6]].append((k, solutions[i][4])) table.add_hline() table.add_hline() # add syb if fname in bestever: if len(bestever[fname]) > 1: table.add_row("syb", bestever[fname][1], bestever[fname][0], "--", "--", "--", "--") objs['syb'].append((k, bestever[fname][1])) else: table.add_row("syb", "--", bestever[fname][0], "--", "--", "--", "--") table.add_hline() k += 1 if k > 0: self.__addTimePlots(doc, options, coords) for o in options: coords[o].clear() k = 0 if len(objs) > 0: self.__addObjPlots(doc, options, objs, pol) for o in objs.keys(): objs[o].clear()
section.append(subsection) print("create subsection: " + prevsubsec) if len(parts) > 2: subsubsection = Subsubsection('%s' % (parts[2].replace("_", "\_"))) subsection.append(subsubsection) print("create subsubsection: " + parts[2]) else: subsubsection = Subsubsection('%s' % (parts[1].replace("_", "\_"))) subsection.append(subsubsection) print("create subsubsection: " + parts[1]) if solutions[0][3] == 'SAT': solutions.sort(key=lambda x: (x[3], x[1])) table = Table('l|r|l|r|r') subsubsection.append(table) table.add_hline() table.add_row(("Param.", 'Status', "\#Sol", 'Time(sec)', 'Nodes')) table.add_hline() for i in range(0, len(solutions)): table.add_row((solutions[i][6], solutions[i][5], solutions[i][0], solutions[i][1], solutions[i][2])) coords[solutions[i][6]].append((k, solutions[i][1])) table.add_hline() else: # sort for MIN type = 'MIN' solutions.sort(key=lambda x: (x[3], x[4], x[1])) best = solutions[0][4] # check first row and last row if solutions[0][3] == 'MAX' or solutions[len(solutions) - 1][3] == 'MAX': solutions.sort(key=lambda x: (x[3], -x[4], x[1]))
if len(parts) > 2: subsubsection = Subsubsection('%s' % (parts[2]))#.replace("_", "\_"))) subsection.append(subsubsection) print("create subsubsection: " + parts[2]) else: subsubsection = Subsubsection('%s' % (parts[1]))#.replace("_", "\_"))) subsection.append(subsubsection) print("create subsubsection: " + parts[1]) pol=solutions[0][3] if solutions[0][3] == 'SAT': solutions.sort(key=lambda x: (x[3], x[1])) table = Tabular('l|r|l|r|r|r') subsubsection.append(table) table.add_hline() table.add_row(("Config.", 'Status', "#Sol", 'Time(sec)', 'Build(sec)', 'Nodes')) table.add_hline() for i in range(0, len(solutions)): table.add_row((solutions[i][6], solutions[i][5], solutions[i][0], solutions[i][1], solutions[i][7], solutions[i][2])) coords[solutions[i][6]].append((k, solutions[i][1])) table.add_hline() table.add_hline() # add syb if fname in bestever : table.add_row("syb", bestever[fname][0], "--", "--", "--", "--") table.add_hline() else: # sort for MIN