当前位置: 首页>>代码示例>>Python>>正文


Python Table.add_row方法代码示例

本文整理汇总了Python中table.Table.add_row方法的典型用法代码示例。如果您正苦于以下问题:Python Table.add_row方法的具体用法?Python Table.add_row怎么用?Python Table.add_row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在table.Table的用法示例。


在下文中一共展示了Table.add_row方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generate_speedup_table

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
    def generate_speedup_table(self):

        table = Table()

        # prepare header
        header = ["procedure"]
        for size in self.data.sizes:
            header.append('%d B' % size)

        table.set_header(header)

        reference_time = {}
        for size in self.data.sizes:
            time = self.data.get(self.data.procedures[0], size)
            reference_time[size] = time

        # get data
        for proc in self.data.procedures:
            measurments = self.data.data_for_procedure(proc)

            row = [proc]
            for item in measurments:
                speedup = reference_time[item.size] / item.time
                row.append('%0.2f' % speedup)

            table.add_row(row)

        return table
开发者ID:dryman,项目名称:sse-popcount,代码行数:30,代码来源:report.py

示例2: generate_time_table

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
    def generate_time_table(self):

        table = Table()

        # prepare header
        header = ["procedure"]
        for size in self.data.sizes:
            header.append('%d B' % size)

        table.set_header(header)

        # get data
        for procedure in self.data.procedures:
            data = self.data.data_for_procedure(procedure)
            row = [procedure]

            for item in data:
                fmt = TIME_PATTERN % item.time
                if item.time == self.data.get_shortest_time(item.size):
                    row.append('**%s**' % fmt)
                else:
                    row.append(fmt)

            table.add_row(row)

        return table
开发者ID:dryman,项目名称:sse-popcount,代码行数:28,代码来源:report.py

示例3: format_table

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
def format_table(data):
    table = Table()
    keys  = data[1].keys()

    # prepare header
    header1 = ["number of spaces"]
    header2 = [""]
    for key in keys:
        header1.append(("%s [cycles/byte]" % key, 3))
        header2.extend(["avg (min)", "avg (max)", "best"])

    table.add_header(header1)
    table.add_header(header2)

    # add data
    for cardinality in xrange(1, 64+1):
        row = ['%d' % cardinality]
        measurements = data[cardinality]
        for meas in measurements.values():
            row.append('%0.3f' % min(meas.values))
            row.append('%0.3f' % max(meas.values))
            row.append('%0.3f' % meas.best)

        table.add_row(row)

    return table
开发者ID:WojciechMula,项目名称:toys,代码行数:28,代码来源:format.py

示例4: print_results

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
def print_results(result_files, out_format):
    """Builds a table with the parsed results. Used when there is only one
    result file.

    """
    categories = transpose_result_data(result_files)
    columns = [result.short_name() for result in result_files]
    columns.insert(0, "Benchmark")
    table = Table(columns)

    geomean = None
    for key in categories:
        scores = [run[1] for run in categories[key]]
        entries = ["%.2f +- %.2f" % score for score in scores]
        entries.insert(0, key)
        if key == 'Geomean':
            geomean = entries
        else:
            table.add_row(entries)

    if geomean is not None:
        table.add_row(geomean)

    if out_format == 'terminal':
        table.dump_to_terminal()
    elif out_format == 'remarkup':
        table.dump_to_remarkup()
    else:
        raise RuntimeError("Unknown output format: %s" % out_format)
开发者ID:CryQ,项目名称:hhvm,代码行数:31,代码来源:significance.py

示例5: format_table

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
def format_table(data):
    vector_size  = list(set(key[0] for key in data.iterkeys()))
    vector_count = list(set(key[1] for key in data.iterkeys()))
    procedures   = data.values()[0].keys()

    vector_size.sort()
    vector_count.sort()

    # prepare header
    table = Table()
    table.add_header(["procedure"] + [("%d vectors" % c, 2) for c in vector_count])
    h = [""]
    t = ["avg cycles", "speedup"]
    for _ in vector_count:
        h.extend(t)
    table.add_header(h)
    
    # prepare data
    for size in vector_size:
        table.add_row([("*vector size %d*" % size, len(vector_count)*2 + 1)])
        for procedure in procedures:
            row = []
            row.append(procedure)

            for count in vector_count:
                key = (size, count)
                measurement = data[key]
                row.append('%0.3f' % measurement[procedure].avg)
                row.append('%0.2f' % measurement[procedure].speedup)

            table.add_row(row)

    print table
开发者ID:WojciechMula,项目名称:toys,代码行数:35,代码来源:format.py

示例6: MainScreen

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
class MainScreen(BoxLayout):
    """docstring for MainScreen"""
    def __init__(self):
        super(MainScreen, self).__init__()
        self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
        self._keyboard.bind(on_key_down=self._on_keyboard_down)
        self.my_table = Table()
        self.my_table.cols = 2
        self.my_table.add_button_row('123', '456')
        for i in range(110):
            self.my_table.add_row([Button, {'text': 'button%s' % i,
                                            'color_widget': [0, 0, 0.5, 1],
                                            'color_click': [0, 1, 0, 1]
                                            }], 
                                  [TextInput, {'text': 'textinput%s' % i,
                                               'color_click': [1, 0, .5, 1]
                                               }])
        self.my_table.label_panel.visible = False
        self.my_table.label_panel.height_widget = 50
        self.my_table.number_panel.auto_width = False
        self.my_table.number_panel.width_widget = 100
        self.my_table.number_panel.visible = False
        self.my_table.choose_row(3)
        self.my_table.del_row(5)
        self.my_table.grid.color = [1, 0, 0, 1]
        self.my_table.label_panel.color = [0, 1, 0, 1]
        self.my_table.number_panel.color = [0, 0, 1, 1]
        self.my_table.scroll_view.bar_width = 10
        self.my_table.scroll_view.scroll_type = ['bars']
        self.my_table.grid.cells[0][0].text = 'edited button text'
        self.my_table.grid.cells[1][1].text = 'edited textinput text'
        self.my_table.grid.cells[3][0].height = 100
        self.my_table.label_panel.labels[1].text = 'New name'
        print "ROW COUNT:", self.my_table.row_count
        self.add_widget(self.my_table)

    def _keyboard_closed(self):
        pass

    def _on_keyboard_down(self, keyboard, keycode, text, modifiers):
        """ Method of pressing keyboard  """
        if keycode[0] == 273:   # UP
            print keycode
            self.my_table.scroll_view.up()
        if keycode[0] == 274:   # DOWN
            print keycode
            self.my_table.scroll_view.down()
        if keycode[0] == 281:   # PageDown
            print keycode
            self.my_table.scroll_view.pgdn()
        if keycode[0] == 280:   # PageUp
            print keycode
            self.my_table.scroll_view.pgup()
        if keycode[0] == 278:   # Home
            print keycode
            self.my_table.scroll_view.home()
        if keycode[0] == 279:   # End
            print keycode
            self.my_table.scroll_view.end()
开发者ID:Seg-mel,项目名称:kivy_table_widget,代码行数:61,代码来源:example.py

示例7: main

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
def main():
    
    table = Table()
    reg   = FunctionRegistry()

    table.set_header(["procedure", "description"])
    for proc, dsc in reg.functions.iteritems():
        table.add_row([proc, dsc])

    print table
开发者ID:WojciechMula,项目名称:sse-popcount,代码行数:12,代码来源:readme_listproc.py

示例8: _preprocess

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
    def _preprocess(self):
        # Set time offsets
        starttime = min([ trace.get_init_time() for trace in self.traces ])
        for trace in self.traces:
            trace.time_offset = trace.get_init_time() - starttime
        trace_times = [ trace.get_next_event_time() for trace in self.traces ]

        if self.export_data:
            place_counters = [place_counter_name(p)
                              for p in self.project.nets[0].places()
                              if p.trace_tokens]

            ri = ExportRunInstance(
                self,
                [ t for t in self.project.nets[0].transitions() if t.trace_fire ],
                [ (p, i) for p in self.project.nets[0].places()
                         for i, tracing in enumerate(p.trace_tokens_functions)
                         if tracing.return_numpy_type != 'O' ],
                ExportRunInstance.basic_header + place_counters)
        else:
            ri = RunInstance(
                self.project, self.process_count)

        index = 0
        timeline = Table([("process", "<i4"), ("pointer", "<i4")], 100)
        full_timeline = Table([("process", "<i4"), ("pointer", "<i4")], 100)
        while True:

            # Searching for trace with minimal event time
            minimal_time_index = utils.index_of_minimal_value(trace_times)
            if minimal_time_index is None:
                break

            trace = self.traces[minimal_time_index]

            full_timeline.add_row((minimal_time_index, trace.pointer))

            # Timeline update
            if trace.is_next_event_visible():
                timeline.add_row(full_timeline[index])

            trace.process_event(ri)
            trace_times[minimal_time_index] = trace.get_next_event_time()

            index += 1

        self.data = Table([], 0)
        if self.export_data:
            self.data = ri.get_table()

        timeline.trim()
        full_timeline.trim()
        self.timeline, self.full_timeline = timeline, full_timeline

        self.missed_receives = ri.missed_receives
开发者ID:DiPi22,项目名称:kaira,代码行数:57,代码来源:tracelog.py

示例9: print_comparison_results

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
def print_comparison_results(result_files, out_format):
    """Builds a table of the various gathered results and prints it out.

    The table also includes an extra column for deltas and adds entries for
    significant changes between the last two provided files.

    """
    def entries_for_scores(key, scores):
        """Returns entries for the next row, prepending the category name and
        appending any significant changes.

        """
        old_score, old_ci = scores[-2]
        new_score, new_ci = scores[-1]
        entries = ["%.2f +- %.2f" % score for score in scores]
        entries.insert(0, key)
        if confidence_intervals_overlap(old_score, old_ci, new_score, new_ci):
            entries.append("")
        else:
            change = percent_delta(old_score, new_score)
            if change < 0.0:
                change_str = "%.4f%% slower" % (change * 100.0)
                entries.append(slower(out_format, change_str))
            else:
                change_str = "+%.4f%% faster" % (change * 100.0)
                entries.append(faster(out_format, change_str))
        return entries

    categories = transpose_result_data(result_files)
    columns = [result.short_name() for result in result_files]
    columns.insert(0, "Benchmark")
    columns.append("Deltas")
    table = Table(columns)

    geomean = None
    for key in categories:
        entries = entries_for_scores(key, [run[1] for run in categories[key]])
        if key == 'Geomean':
            geomean = entries
            geomean[0] = bold(out_format, geomean[0])
        else:
            table.add_row(entries)

    if geomean is not None:
        table.add_row(geomean)

    if out_format == 'terminal':
        table.dump_to_terminal()
    elif out_format == 'remarkup':
        table.dump_to_remarkup()
    else:
        raise RuntimeError("Unknown output format: %s" % out_format)
开发者ID:CryQ,项目名称:hhvm,代码行数:54,代码来源:significance.py

示例10: generate_procedures_descriptions

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
    def generate_procedures_descriptions(self):

        definitions = self.__parse_cpp()

        table = Table()
        header = ["procedure", "description"]
        table.set_header(header)

        for proc, desc in definitions.iteritems():
            if proc in self.data.procedures:
                table.add_row([proc, desc])

        return table
开发者ID:Eppie,项目名称:sse-popcount,代码行数:15,代码来源:report.py

示例11: generate_procedures_descriptions

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
    def generate_procedures_descriptions(self):
        
        reg = FunctionRegistry()

        table = Table()
        header = ["procedure", "description"]
        table.set_header(header)

        for proc, desc in reg.functions.iteritems():
            if proc in self.data.procedures:
                table.add_row([proc, desc])

        return table
开发者ID:WojciechMula,项目名称:sse-popcount,代码行数:15,代码来源:report.py

示例12: generate_time_table_for_size

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
    def generate_time_table_for_size(self, size):

        table = Table()
        table.set_header(["procedure", "time [s]", "relative time"])

        chars = 50

        data = self.data.data_for_size(size)
        max_time = max(item.time for item in data)

        for item in data:
            time = TIME_PATTERN % item.time
            bar  = unicode_bar(item.time/max_time, chars)
            table.add_row([item.procedure, time, bar])

        return table
开发者ID:dryman,项目名称:sse-popcount,代码行数:18,代码来源:report.py

示例13: print_comparison_results

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
def print_comparison_results(result_files, out_format, lower_is_better):
    """Builds a table of the various gathered results and prints it out.

    The table also includes an extra column for deltas and adds entries for
    significant changes between the last two provided files.

    """
    def entries_for_scores(key, scores):
        """Returns entries for the next row, prepending the category name and
        appending any significant changes.

        """
        old_score, old_ci = scores[-2]
        new_score, new_ci = scores[-1]
        entries = ["{0:.2f} +- {1:.2f}".format(*score) for score in scores]
        entries.insert(0, key)
        if confidence_intervals_overlap(old_score, old_ci, new_score, new_ci):
            entries.append("")
        else:
            change = percent_delta(old_score, new_score)
            if is_slower(change, lower_is_better):
                change_str = "{0:.4f}% slower".format((change * 100.0))
                entries.append(slower(out_format, change_str))
            else:
                change_str = "+{0:.4f}% faster".format((change * 100.0))
                entries.append(faster(out_format, change_str))
        return entries

    categories = transpose_result_data(result_files)
    columns = [result.short_name() for result in result_files]
    columns.insert(0, "Benchmark")
    columns.append("Deltas")
    table = Table(columns)

    geomean = None
    for key in categories:
        entries = entries_for_scores(key, [run[1] for run in categories[key]])
        if key == 'Geomean':
            geomean = entries
            geomean[0] = bold(out_format, geomean[0])
        else:
            table.add_row(entries)

    if geomean is not None:
        table.add_row(geomean)

    table.dump(out_format)
开发者ID:runt18,项目名称:hhvm,代码行数:49,代码来源:significance.py

示例14: TableLayoutTest

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
class TableLayoutTest(unittest.TestCase):
  """Tests for TableLayout"""

  def setUp(self):
    # Create a table with 3 columns and 2 rows.
    self.table = Table('Table', ['Col1', 'Col2', 'Col3'])
    self.table.add_row(['a', 'b', 'c'])
    self.table.add_row(['d', 'e', 'f'])

    self.workbook = MockWorkbook()
    self.style = TableStyle(self.workbook, self.table)

  def test_no_style(self):
    self.assertRaises(ValueError, TableLayout, None, self.table)

  def test_null_table(self):
    self.assertRaises(ValueError, TableLayout, self.style, None)

  def test_size(self):
    layout = TableLayout(self.style, self.table)
    # The height of the layout includes 1 extra for the headers.
    self.assertEquals((3, 3), layout.size())

  def test_draw(self):
    sheet = MockSheet('Sheet1')
    start_position = (0, 0)
    layout = TableLayout(self.style, self.table)
    layout.draw(sheet, start_position)

    # Expect a 3 x 3 grid of cells with the table data.
    self.assertEquals('Col1', sheet.read(0, 0))
    self.assertEquals('Col2', sheet.read(0, 1))
    self.assertEquals('Col3', sheet.read(0, 2))
    self.assertIsNone(sheet.read(0, 3))
    self.assertEquals('a', sheet.read(1, 0))
    self.assertEquals('b', sheet.read(1, 1))
    self.assertEquals('c', sheet.read(1, 2))
    self.assertIsNone(sheet.read(1, 3))
    self.assertEquals('d', sheet.read(2, 0))
    self.assertEquals('e', sheet.read(2, 1))
    self.assertEquals('f', sheet.read(2, 2))
    self.assertIsNone(sheet.read(2, 3))
    self.assertIsNone(sheet.read(3, 0))
    self.assertIsNone(sheet.read(3, 1))
    self.assertIsNone(sheet.read(3, 2))
    self.assertIsNone(sheet.read(3, 3))
开发者ID:tordable,项目名称:XlsxReports,代码行数:48,代码来源:layout_test.py

示例15: main

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import add_row [as 别名]
def main():

    with open(sys.argv[1], 'rt') as f:
        available_procedures, data = load(f)
   
    procedures = ["std", "SSE", "AVX2", "binsearch"]

    header = ["size A", "size B", "size ratio"]
    for proc in procedures:
        if proc in available_procedures:
            header.append("%s [us]" % proc)

    table = Table()
    table.set_header(header)

    for key, values in data.iteritems():
        small_size, large_size = key

        row = [
            '%d' % small_size,
            '%d' % large_size,
            '%0.2f' % (large_size/float(small_size)),
        ]

        for proc in procedures:
            if proc in available_procedures:
                row.append('%d' % values[proc])

        table.add_row(row)

        def speedup(base, new):
            try:
                coef = base/float(new)
            except ZeroDivisionError:
                coef = float(base)

            return 'x %0.2f' % coef

        row = ["", "", "", ""]
        for proc in procedures:
            if proc != 'std' and proc in available_procedures:
                row.append(speedup(values['std'], values[proc]))

        table.add_row(row)

    print table
开发者ID:WojciechMula,项目名称:toys,代码行数:48,代码来源:report.py


注:本文中的table.Table.add_row方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。