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


Python Table.trim方法代码示例

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


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

示例1: _preprocess

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import trim [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

示例2: load_csv

# 需要导入模块: from table import Table [as 别名]
# 或者: from table.Table import trim [as 别名]
def load_csv(filename, app, settings):
    if settings is None:
        settings = show_csv_settings_dialog(app.window)
    if settings is None:
        return (None, None) # settings was canceled

    delimiter, quotechar, has_header, has_types = settings
    with open(filename, "rb") as csvfile:
        csvreader = csv.reader(
            csvfile, delimiter=delimiter, quotechar=quotechar)

        try:
            types = None
            if has_types:
                types = csvreader.next()

            header = None
            if has_header:
                header = csvreader.next()

            row = csvreader.next()  # first row with data
        except StopIteration:
            table = Table([("V0", "object")], 0)
            return (table, None);

        if types is None:
            types = ["object"] * len(row)
        if header is None:
            header = ["V {0}".format(i + 1) for i in range(len(row))]
        cols_description = zip(header, types)

        table = Table(cols_description, 100)
        row = [None if value == '' else value for value in row]
        table.add_row(row) # add the first loaded row with data
        for row in csvreader:
            row = [None if value == '' else value for value in row]
            table.add_row(row);
        table.trim()
        return (table, settings)
开发者ID:DiPi22,项目名称:kaira,代码行数:41,代码来源:datatypes.py


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